-
Notifications
You must be signed in to change notification settings - Fork 0
/
airrecord_models.rb
88 lines (71 loc) · 3.14 KB
/
airrecord_models.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# I should check how much of this I need.
Airrecord.api_key = ENV["AIRRECORD_API_KEY"]
class Keyboard < Airrecord::Table
self.base_key = "appeUTAWBfz4YzHtJ"
self.table_name = "Keyboards"
has_many :practice_sessions, class: "PracticeSession", column: "Practice Sessions"
end
class Domain < Airrecord::Table
self.base_key = "appeUTAWBfz4YzHtJ"
self.table_name = "Domains"
has_many :exercises, class: "Exercise", column: "Exercises"
has_many :exercise_sets, class: "ExerciseSet", column: "Exercise Sets"
end
class ExerciseSet < Airrecord::Table
self.base_key = "appeUTAWBfz4YzHtJ"
self.table_name = "Exercise Sets"
belongs_to :domain, class: "Domain", column: "Domain"
has_many :exercises, class: "Exercise", column: "Exercises"
end
class Exercise < Airrecord::Table
self.base_key = "appeUTAWBfz4YzHtJ"
self.table_name = "Exercises"
belongs_to :domain, class: "Domain", column: "Domain"
belongs_to :set, class: "ExerciseSet", column: "Exercise Set"
has_many :exercise_increments, class: "ExerciseIncrement", column: "Exercise Increments"
# Not sure if I need this one
has_many :exercises_practice_sessions, class: "ExercisesPracticeSession", column: "Exercises Practice Sessions"
has_many :practice_sessions, class: "PracticeSession", column: "Practice Sessions"
end
class ExerciseIncrement < Airrecord::Table
self.base_key = "appeUTAWBfz4YzHtJ"
self.table_name = "Exercise Increments"
belongs_to :domain, class: "Domain", column: "Domain"
belongs_to :set, class: "ExerciseSet", column: "Exercise Set"
belongs_to :exercise, class: "Exercise", column: "Exercise"
# Does this link to practice session or exercise practice session?
belongs_to :tk_completion, class: "ExercisesPracticeSessions", column: "TK Completion"
belongs_to :lik_completion, class: "ExercisesPracticeSessions", column: "LIK Completion"
end
class PracticeSession < Airrecord::Table
self.base_key = "appeUTAWBfz4YzHtJ"
self.table_name = "Practice Sessions"
def completed_increments
completed_increments = []
keyboard = self[:keyboard][:acronym]
# sleep(0.21)
self[:exercises_practice_sessions].each do |eps|
# sleep(0.21)
if keyboard == "TK" && eps[:tk_completed]
completed_increments.concat(eps[:tk_completed])
elsif keyboard == "LIK" && eps[:lik_completed]
completed_increments.concat(eps[:lik_completed])
end
end
return completed_increments
end
def completed_increment_count
self.completed_increments.count
end
belongs_to :keyboard, class: "Keyboard", column: "Keyboard"
has_many :exercises_practice_sessions, class: "ExercisesPracticeSession", column: "Exercises Practice Sessions"
has_many :exercises, class: "Exercise", column: "Exercises"
end
class ExercisesPracticeSession < Airrecord::Table
self.base_key = "appeUTAWBfz4YzHtJ"
self.table_name = "Exercises Practice Sessions"
belongs_to :practice_session, class: "PracticeSession", column: "Practice Session"
belongs_to :exercise, class: "Exercise", column: "Exercise"
has_many :tk_completed, class: "ExerciseIncrement", column: "TK Completed"
has_many :lik_completed, class: "ExerciseIncrement", column: "LIK Completed"
end