Skip to content

Commit

Permalink
Update method to use namespacing and add scopes for filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel-k committed Apr 11, 2024
1 parent 21a9752 commit ade32b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions app/controllers/api/v1/curura/rankings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def set_leaderboards
end

def games
binding.pry
@games ||= CururaGame.today
@games ||= ::Curura::Game.today
end

def country
Expand Down
4 changes: 4 additions & 0 deletions app/models/curura/game.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
class Curura::Game < ApplicationRecord
validates :score, :country, :start_time, presence: true

scope :today, -> { where("start_time >= ?", Time.zone.now.beginning_of_day) }
scope :won_above_score, ->(score) { where("score > ?", score) }
scope :country, ->(country) { where(country: country) }
end

0 comments on commit ade32b4

Please sign in to comment.