Class: Dashboard

Inherits:
ApplicationRecord show all
Defined in:
app/models/dashboard.rb

Overview

This model holds the statistics for each user’s gaming history. It allows a user to track their progress and history for each game. Each user has a special “streak record” with game_id of -1 to track combined data for streak computations

Raises:

  • (ValidationError)

    if an attempt to change the streak record to a non steak record is done after record creation

Instance Attribute Summary collapse

Instance Attribute Details

#game_idInteger

The game for which the record is. Foreign key referenced to the associated ‘Game` model. Id is -1 for streak record

Returns:

  • (Integer)

    the current value of game_id



13
14
15
# File 'app/models/dashboard.rb', line 13

def game_id
  @game_id
end

#played_onDate

The date on which the user played the game referenced in this entry

Returns:

  • (Date)

    the current value of played_on



13
14
15
# File 'app/models/dashboard.rb', line 13

def played_on
  @played_on
end

#scoreInteger

The score the user attained playing the game on the specific date

Returns:

  • (Integer)

    the current value of score



13
14
15
# File 'app/models/dashboard.rb', line 13

def score
  @score
end

#streak_countInteger

The highest streak tracking consecutive days game played by user. Only set when streak_record is true

Returns:

  • (Integer)

    the current value of streak_count



13
14
15
# File 'app/models/dashboard.rb', line 13

def streak_count
  @streak_count
end

#user_idInteger

The user for whom the record is. Foreign key referenced to the associated ‘User` model

Returns:

  • (Integer)

    the current value of user_id



13
14
15
# File 'app/models/dashboard.rb', line 13

def user_id
  @user_id
end