Skip to content
Snippets Groups Projects
Commit 4024fde3 authored by Rysev, Gleb (UG - SISC)'s avatar Rysev, Gleb (UG - SISC)
Browse files

Push notifications added to goals generation

parent a24e07aa
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment