Skip to content

Instantly share code, notes, and snippets.

@rdetert
Last active December 29, 2015 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdetert/7633417 to your computer and use it in GitHub Desktop.
Save rdetert/7633417 to your computer and use it in GitHub Desktop.
Sport Statistics
class SportStatistic
include Mongoid::Document
end
class AthleteStatistic < SportStatistic
end
class SoccerAthleteStatistic < AthleteStatistic
field: goals
field: assists
field: red_cards
field: yellow_cards
end
class GameStatistic < SportStatistic
end
class SoccerGameStatistic < GameStatistic
field: penalty_time
field: red_cards
field: yellow_cards
end
class User
include Mongoid::Document
field :username
field :password
field :email
end
class Coach < User
end
class Athlete < User
# will be broken down by sport, one sub document per sport
# When a match_statistic is added, these stats will be recalculated to average them all by sport
embeds_many AthleteStatistics, as: :career_statistics
# broken down by sport, multiple sub documents per sport
embeds_many AthleteStatistics, as: :match_statistics
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment