From 850837ad795770a0e1e7b3f1de0547944ed732c7 Mon Sep 17 00:00:00 2001 From: tarentomaheshvakkund <139739142+tarentomaheshvakkund@users.noreply.github.com> Date: Mon, 8 Jul 2024 18:41:41 +0530 Subject: [PATCH] KB-5718 | DEV|Assessment |BE| Capturing the starttime and endtime of the Batches while creating the batch for Assessment 1.Add 5hrs30mins to the current time stamp, made it configurable based on flag. 2.Add values to string constants. --- .../actors/coursebatch/dao/impl/CourseBatchDaoImpl.java | 5 +++++ .../main/java/org/sunbird/learner/util/CourseBatchUtil.java | 4 ++-- .../actors/coursebatch/CourseBatchManagementActor.java | 4 ++-- .../main/java/org/sunbird/common/models/util/JsonKey.java | 1 + .../src/main/resources/externalresource.properties | 1 + 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/course-mw/course-actors-common/src/main/java/org/sunbird/learner/actors/coursebatch/dao/impl/CourseBatchDaoImpl.java b/course-mw/course-actors-common/src/main/java/org/sunbird/learner/actors/coursebatch/dao/impl/CourseBatchDaoImpl.java index 1e7677f25..b96920b5b 100644 --- a/course-mw/course-actors-common/src/main/java/org/sunbird/learner/actors/coursebatch/dao/impl/CourseBatchDaoImpl.java +++ b/course-mw/course-actors-common/src/main/java/org/sunbird/learner/actors/coursebatch/dao/impl/CourseBatchDaoImpl.java @@ -198,6 +198,11 @@ private static void processStartEndDate(Map map, String timeType calendar.set(Calendar.HOUR_OF_DAY, timeCalendar.get(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, timeCalendar.get(Calendar.MINUTE)); calendar.set(Calendar.SECOND, timeCalendar.get(Calendar.SECOND)); + if(ProjectUtil.getConfigValue(JsonKey.ADD_EXTRA_HOURS_MINS).equalsIgnoreCase("true")){ + calendar.add(Calendar.HOUR_OF_DAY, 5); + calendar.add(Calendar.MINUTE, 30); + log.info("Added 5hours 30mins to the start_date and end_date"); + } map.put(dateType, calendar.getTime()); log.info("Updated date in map with key {}: {}", dateType, calendar.getTime()); } diff --git a/course-mw/course-actors-common/src/main/java/org/sunbird/learner/util/CourseBatchUtil.java b/course-mw/course-actors-common/src/main/java/org/sunbird/learner/util/CourseBatchUtil.java index 4be4a8213..4c011aa44 100644 --- a/course-mw/course-actors-common/src/main/java/org/sunbird/learner/util/CourseBatchUtil.java +++ b/course-mw/course-actors-common/src/main/java/org/sunbird/learner/util/CourseBatchUtil.java @@ -186,8 +186,8 @@ public static Map esCourseMapping(CourseBatch courseBatch, Strin dateTimeFormat.setTimeZone(TimeZone.getTimeZone(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_TIMEZONE))); Map esCourseMap = mapper.convertValue(courseBatch, Map.class); if (courseBatch.getStartTime() != null && courseBatch.getEndTime() != null) { - esCourseMap.put("startTime", courseBatch.getStartDate()); - esCourseMap.put("endTime", courseBatch.getEndDate()); + esCourseMap.put(JsonKey.START_TIME, courseBatch.getStartDate()); + esCourseMap.put(JsonKey.END_TIME, courseBatch.getEndDate()); } changeInDateFormat.forEach(key -> { if (null != esCourseMap.get(key)) diff --git a/course-mw/course-actors/src/main/java/org/sunbird/learner/actors/coursebatch/CourseBatchManagementActor.java b/course-mw/course-actors/src/main/java/org/sunbird/learner/actors/coursebatch/CourseBatchManagementActor.java index 656cd3c6a..44db9e1de 100644 --- a/course-mw/course-actors/src/main/java/org/sunbird/learner/actors/coursebatch/CourseBatchManagementActor.java +++ b/course-mw/course-actors/src/main/java/org/sunbird/learner/actors/coursebatch/CourseBatchManagementActor.java @@ -722,8 +722,8 @@ private void updateCollection(RequestContext requestContext, Map data.put("createdFor", courseBatch.getOrDefault(JsonKey.COURSE_CREATED_FOR, new ArrayList<>())); data.put("startDate", courseBatch.getOrDefault(JsonKey.START_DATE, "")); data.put("endDate", courseBatch.getOrDefault(JsonKey.END_DATE, null)); - data.put("startTime", courseBatch.getOrDefault("startTime", null)); - data.put("endTime", courseBatch.getOrDefault("endTime", null)); + data.put("startTime", courseBatch.getOrDefault(JsonKey.START_TIME, null)); + data.put("endTime", courseBatch.getOrDefault(JsonKey.END_TIME, null)); data.put("enrollmentType", courseBatch.getOrDefault(JsonKey.ENROLLMENT_TYPE, "")); data.put("status", courseBatch.getOrDefault(JsonKey.STATUS, "")); data.put("batchAttributes", courseBatch.getOrDefault(CourseJsonKey.BATCH_ATTRIBUTES, new HashMap())); diff --git a/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/JsonKey.java b/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/JsonKey.java index 34998c4e2..796e1fff0 100644 --- a/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/JsonKey.java +++ b/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/JsonKey.java @@ -1141,6 +1141,7 @@ public final class JsonKey { public static final String COURSE_ENROLL_ALLOWED_PRIMARY_CATEGORY = "course_enroll_allowed_primary_category"; public static final String START_DATE_BATCH = "start_date"; public static final String END_DATE_BATCH = "end_date"; + public static final String ADD_EXTRA_HOURS_MINS = "addExtraHrsAndMins.start_date_end_date"; private JsonKey() {} } diff --git a/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/resources/externalresource.properties b/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/resources/externalresource.properties index 8d8ceeb7b..bd832b787 100644 --- a/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/resources/externalresource.properties +++ b/course-mw/sunbird-util/sunbird-platform-core/common-util/src/main/resources/externalresource.properties @@ -224,3 +224,4 @@ content_bucket=/content-store/content static_host_url=https://static.karmayogiprod.nic.in profile_update_url=/app/user-profile/details course_enroll_allowed_primary_category=Course,Blended Program,Standalone Assessment +addExtraHrsAndMins.start_date_end_date=true