diff --git a/app/helpers/goals_helper.rb b/app/helpers/goals_helper.rb index 6b69090b785ef6e262ba06dd2246298ddafa8e82..5c440c6b525ab43fda393231d7937644954bfba7 100644 --- a/app/helpers/goals_helper.rb +++ b/app/helpers/goals_helper.rb @@ -116,8 +116,9 @@ module GoalsHelper def generateMonthlyGoals if Date.today == Date.today.beginning_of_month - pushGoalNotification("Your new goals were generated") + deleteLastMonthsGoals + pushGoalNotification("New Goals generated!") @goals = Goals.where(user_id: current_user.id, goaltype: "monthlyHabitStreak") monthlyHabitsCreated = "false" @@ -174,27 +175,7 @@ module GoalsHelper @goal = Goals.new(:title => "Streak Beater", :description => "Beat your maximum streak for " + @habit.title, :counter => @habit.streak, :target => @habit.max_streak, :user_id => current_user.id, :goaltype => "monthlyHabitStreak", :completed => "false", :habit_id => @habit.id) @goal.save - - # numGoals = (NumCurrUserHabits / 4).ceil + 1 - # for i in 0..numGoals - # # not sure about purpose/performance or if this actually works, but should get a random habit - # targetHabit = current_user.habits.order("RANDOM()").first() - # currentStreakDecile = findWhichDecileTargetHabitStreakFallsIn(targetHabit.streak) - # if currentStreakDecile == 9 - # targetStreak = targetHabit.streak + 30 - # # not sure about this part, but probably same algorithm can be used - # # to find decile and then use "Same Decision System as for streak decile" - # currentDurationDecile = findWhichDecileTargetHabitDurationFallsIn() - # targetDuration = "foo" - # else - # # not sure about CurrentStreakDecileAVG, is it really necessary? - # if targetHabit.streak < CurrentStreakDecileAVG - # targetStreak = currentStreakDecileAVG - # else - # targetStreak = nextDecileUpLowerBoundary + 1 - # end - # end - # end + end end end