CodeSmels fix
@@ -27,6 +27,7 @@ public class HabitStatusServiceImpl implements HabitStatusService {
/**
* Method save {@link HabitStatusCalendar} for user.
+ *
* @param habit target habit
* @param user target habit
*/
@@ -46,6 +47,7 @@ public class HabitStatusServiceImpl implements HabitStatusService {
/**
* Method delete {@link HabitStatus} by user.
+ *
* @param userId target userId
*/
@Override
@@ -55,6 +57,7 @@ public class HabitStatusServiceImpl implements HabitStatusService {
/**
* Find {@link HabitStatus} by habit and user id's.
+ *
* @param habitId target habit Id
* @param userId target user Id
* @return {@link HabitStatusDto}
@@ -66,6 +69,7 @@ public class HabitStatusServiceImpl implements HabitStatusService {
/**
* Method enroll {@link greencity.entity.Habit}.
+ *
* @param habitId - id of habit which we enroll
* @return {@link HabitStatusDto}
*/
@@ -83,12 +87,7 @@ public class HabitStatusServiceImpl implements HabitStatusService {
intervalBetweenDates = Duration.between(lastEnrollmentDate, todayDate).toHours();
}
- if (lastEnrollmentDate == null) {
- int habitStreak = habitStatus.getHabitStreak();
- habitStatus.setHabitStreak(++habitStreak);
- habitCalendar = new HabitStatusCalendar(todayDate, habitStatus);
- habitStatusCalendarService.save(habitCalendar);
- } else if (intervalBetweenDates >= 20 && intervalBetweenDates <= 24) {
+ if ((intervalBetweenDates >= 20 && intervalBetweenDates <= 24) | lastEnrollmentDate == null) {
int habitStreak = habitStatus.getHabitStreak();
habitStatus.setHabitStreak(++habitStreak);
habitCalendar = new HabitStatusCalendar(todayDate, habitStatus);
@@ -108,6 +107,7 @@ public class HabitStatusServiceImpl implements HabitStatusService {
/**
* Method unenroll Habit in defined date.
+ *
* @param habitId - id of habit
* @param dateTime - date we want unenroll
*/
@@ -143,6 +143,7 @@ public class HabitStatusServiceImpl implements HabitStatusService {
/**
* Method enroll habit for defined date.
+ *
* @param habitId - id of habit
* @param date - date we want enroll
*/
