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

Merge branch 'Development' of...

Merge branch 'Development' of gitlab.eps.surrey.ac.uk:group-10/habit-tracker-web-app into Development
parents 98bad853 acd1837a
No related branches found
No related tags found
No related merge requests found
Pipeline #30734 failed
...@@ -74,6 +74,7 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] ...@@ -74,6 +74,7 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
# Additional Project Gems # Additional Project Gems
# #
#Have to use feature branch because devise is yet to be patched for omniauth 2 - https://github.com/heartcombo/devise/pull/5327 #Have to use feature branch because devise is yet to be patched for omniauth 2 - https://github.com/heartcombo/devise/pull/5327
gem 'dotenv-rails', require: 'dotenv/rails-now'
gem 'devise', github: 'heartcombo/devise', branch: 'ca-omniauth-2' gem 'devise', github: 'heartcombo/devise', branch: 'ca-omniauth-2'
gem 'omniauth-facebook' gem 'omniauth-facebook'
gem 'omniauth-google-oauth2' gem 'omniauth-google-oauth2'
......
...@@ -2,7 +2,7 @@ module GoalsHelper ...@@ -2,7 +2,7 @@ module GoalsHelper
def getHabitsAmount(current_user) def getHabitsAmount(current_user)
amount = 0 amount = 0
current_user.habits.each do |habit| current_user.habits.each do |habit|
amount = amount + 1 amount = amount + 1
end end
return amount return amount
end end
...@@ -13,7 +13,7 @@ module GoalsHelper ...@@ -13,7 +13,7 @@ module GoalsHelper
@goals.each do |goal| @goals.each do |goal|
if goal.counter != amount if goal.counter != amount
goal.counter = amount goal.counter = amount
end end
if goal.counter >= goal.target if goal.counter >= goal.target
goal.completed = "true" goal.completed = "true"
...@@ -26,19 +26,19 @@ module GoalsHelper ...@@ -26,19 +26,19 @@ module GoalsHelper
@goals = Goals.where(goalType: "habitStreak").or(Goals.where(goalType: "monthlyHabitStreak")) @goals = Goals.where(goalType: "habitStreak").or(Goals.where(goalType: "monthlyHabitStreak"))
@goals.each do |goal| @goals.each do |goal|
if Habit.exists?(goal.habit_id) if Habit.exists?(goal.habit_id)
@habit = Habit.find(goal.habit_id) @habit = Habit.find(goal.habit_id)
currentStreak = @habit.streak currentStreak = @habit.streak
if goal.counter != currentStreak if goal.counter != currentStreak
goal.counter = currentStreak goal.counter = currentStreak
end end
if goal.counter >= goal.target if goal.counter >= goal.target
goal.completed = "true" goal.completed = "true"
end end
goal.save goal.save
else else
goal.destroy goal.destroy
end end
end end
end end
...@@ -84,9 +84,9 @@ module GoalsHelper ...@@ -84,9 +84,9 @@ module GoalsHelper
end end
elsif @allgoals.exists?(title: "First") elsif @allgoals.exists?(title: "First")
else else
@goal = Goals.new(:title => "First", :description => "Create your first habit", :counter => "0", :target => "1", :user_id => current_user.id, @goal = Goals.new(:title => "First", :description => "Create your first habit", :counter => "0", :target => "1", :user_id => current_user.id,
:goaltype => "habitAmount", :completed => "false") :goaltype => "habitAmount", :completed => "false")
@goal.save @goal.save
end end
updateHabitAmountGoals updateHabitAmountGoals
end end
...@@ -97,9 +97,9 @@ module GoalsHelper ...@@ -97,9 +97,9 @@ module GoalsHelper
@habits.each do |habit| @habits.each do |habit|
if @goals.exists?(title: habit.title) if @goals.exists?(title: habit.title)
else else
@goal = Goals.new(:title => habit.title, :description => "Reach Target", :counter => habit.streak, :target => habit.target, @goal = Goals.new(:title => habit.title, :description => "Reach Target", :counter => habit.streak, :target => habit.target,
:user_id => current_user.id, :goaltype => "habitStreak", :completed => "false", :habit_id => habit.id) :user_id => current_user.id, :goaltype => "habitStreak", :completed => "false", :habit_id => habit.id)
@goal.save @goal.save
end end
end end
updateHabitStreakGoals updateHabitStreakGoals
...@@ -143,7 +143,7 @@ module GoalsHelper ...@@ -143,7 +143,7 @@ module GoalsHelper
@habit = @emptyhabits.order("RANDOM()").first() @habit = @emptyhabits.order("RANDOM()").first()
@goal = Goals.new(:title => "Start tracking " + @habit.title, :description => "Reach a streak of 10 for " + @habit.title, :counter => @habit.streak, :target => 10, @goal = Goals.new(:title => "Start tracking " + @habit.title, :description => "Reach a streak of 10 for " + @habit.title, :counter => @habit.streak, :target => 10,
:user_id => current_user.id, :goaltype => "monthlyHabitStreak", :completed => "false", :habit_id => @habit.id) :user_id => current_user.id, :goaltype => "monthlyHabitStreak", :completed => "false", :habit_id => @habit.id)
@goal.save @goal.save
end end
...@@ -165,15 +165,15 @@ module GoalsHelper ...@@ -165,15 +165,15 @@ module GoalsHelper
end end
@goal = Goals.new(:title => "Increase " + @maxhabit.title + " streak", :description => "Your " + @maxhabit.title + " streak is in the top " + percentile.to_s + "% for highest ongoing streak, keep this going this month", @goal = Goals.new(:title => "Increase " + @maxhabit.title + " streak", :description => "Your " + @maxhabit.title + " streak is in the top " + percentile.to_s + "% for highest ongoing streak, keep this going this month",
:counter => @maxhabit.streak, :target => @maxhabit.streak + 25, :counter => @maxhabit.streak, :target => @maxhabit.streak + 25,
:user_id => current_user.id, :goaltype => "monthlyHabitStreak", :completed => "false", :habit_id => @maxhabit.id) :user_id => current_user.id, :goaltype => "monthlyHabitStreak", :completed => "false", :habit_id => @maxhabit.id)
@goal.save @goal.save
@streakhabits = Habit.where("(max_streak - streak) < 30").where("(max_streak - streak) >= 0").where(user_id: current_user.id) @streakhabits = Habit.where("(max_streak - streak) < 30").where("(max_streak - streak) >= 0").where(user_id: current_user.id)
@habit = @streakhabits.order("RANDOM()").first() @habit = @streakhabits.order("RANDOM()").first()
@goal = Goals.new(:title => "Streak Beater", :description => "Beat your maximum streak for " + @habit.title, :counter => @habit.streak, :target => @habit.max_streak, @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) :user_id => current_user.id, :goaltype => "monthlyHabitStreak", :completed => "false", :habit_id => @habit.id)
@goal.save @goal.save
end end
end end
......
...@@ -6,12 +6,12 @@ require 'rails/all' ...@@ -6,12 +6,12 @@ require 'rails/all'
# Require the gems listed in Gemfile, including any gems # Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production. # you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups) Bundler.require(*Rails.groups)
Dotenv::Railtie.load
module Group10HabitTracker module Group10HabitTracker
class Application < Rails::Application class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version. # Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2 config.load_defaults 5.2
# Settings in config/environments/* take precedence over those specified here. # Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers # Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading # -- all .rb files in that directory are automatically loaded after loading
......
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