-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbnotes.js
133 lines (108 loc) · 2.68 KB
/
dbnotes.js
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
// ----------------- CURRENT SONG & QUEUES ------------------ //
currentSong: {
partyID: {
uid: str,
dj_name: str,
artist: str,
title: str,
song_uri: str,
time_priority: 0,
vote_priority: 0,
artwork_url: str
}
}
topTen: {
partyID: {
hashid: {
uid: str,
dj_name: str,
artist: str,
title: str,
song_uri: str,
time_priority: 0,
vote_priority: 0,
artwork_url: str
}
}
}
shadowQueue: {
partyID: {
hashid: {
uid: str,
dj_name: str,
artist: str,
title: str,
song_uri: str,
time_priority: 0,
vote_priority: 0,
artwork_url: str
}
}
}
// ----------------- ATTENDEES ------------------ //
user_parties: {
uid: partyId,
uid: partyId
}
// ----------------- PARTIES ------------------ //
parties: {
partyID: { // partyID === host.uid
name: '',
location: '',
id: partyID, // maybe change this? born of necessity
needSong: bool,
active: bool
}
}
party_djs: {
partyID: {
uid1: {
dj_points: int,
name: str,
personal_queue: {
hashid: {
uid: str,
dj_name: str,
artist: str,
title: str
song_uri: str,
time_priority: 0,
vote_priority: 0
}
}
},
uid2: {
...
}
},
partyID2: {
...
}
}
// ----------------- PERSISTENCE (AM) ------------------ //
djNames: {
uid: 'name'
}
RULES OF QUEUES
1. Top Ten are immutable but can move up/down top ten depending on 1) up/downvotes and 2) time
2. When a song finishes playing, the next song to play is #1 on the Top Ten
3. When a song finishes playing, the next song to go to the Top Ten is the one on the shadow queue with highest priority
4. Shadow Queue consists of one song per user
5. Personal Queues have a limit of 10 songs per user
6. When a song enters the Shadow queue, its priority is based on the DJ points of the user who selected it
7. All songs gain priority at an equal rate while on the shadow queue (and top ten, per rule #1)
8. When a song enters the Top Ten, its 'priority points' are set to zero
THEREFORE
A. When a song finishes playing:
i. Node sets the new Current Song to #1 in Top Ten
ii. Node takes the highest priority song in the shadow queue (call it 'Song X') and adds it to the Top Ten
iii. Node finds DJ of Song X, takes his/her #1 suggestion (from personal queue) and adds it to the Shadow Queue.
iv. When adding 'Song X', Node takes into account DJ points of 'DJ X' to set initial priority
B. When a song is up/downvoted in Top Ten
i. Node listens for this event, and re-orders Top Ten accordingly
ii. Node adjusts DJ points of song suggestor
C. With the passage of time
i. All songs on Shadow Queue gain priority
ii. All songs on Top Ten gain priority
*/