You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/docsite/docs/Internal/concepts.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,5 +4,12 @@ title: Concepts and Vocabulary
4
4
5
5
# Disambiguation
6
6
7
-
## Match/Set
8
-
When we refer to the games played between players, which are reported to Grindcord, we use the term "match" over "set". Despite "set" being more common to refer to a past game, it shadows the term "set", which is a reserved word in programming (the data structure).
7
+
## Use the word `Match` over `Set` to refer to recorded games
8
+
When we refer to the games played between players, which are reported to Grindcord, we use the term "match" over "set".
9
+
10
+
Despite "set" being more common to refer to a past game, it already has a meaning in programming (the data structure) and may cause confusion. Using the word `Set` or `set` in code may also shadow the built-in `Set()` object in code.
11
+
12
+
## GuildMember/User
13
+
Grindcord is built for communities on Discord. Every user of Grindcord must also be a member of a guild (a Discord server) which has Grindcord installed.
14
+
15
+
A user of Grindcord is uniquely identied by their `id` (that we disambiguate as `user_id`), and their participation in a guild with a `guild_id`. So, a [`GuildMember`](https://discord.com/developers/docs/resources/guild#guild-member-object) is an object from the Discord API which represents a [`user`](https://discord.com/developers/docs/resources/user#user-object) and their participation in that guild.
Copy file name to clipboardExpand all lines: apps/docsite/docs/Internal/database.md
+43-10Lines changed: 43 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,19 +13,20 @@ Matches are reported to the backend. These reports contain the data:
13
13
- Match count (3-0)
14
14
- The fighters used by each respective user
15
15
16
-
#####External Dependencies
16
+
# External Dependencies
17
17
18
-
A user of Grindcord SHOULD NOT be stored explicitly in our database. A [`GuildMember`](https://discord.com/developers/docs/resources/guild#get-guild-member) is an external dependency provided by Discord. A [`GuildMember`](https://discord.com/developers/docs/resources/guild#get-guild-member)'s `user_id` on the [`user`](https://discord.com/developers/docs/resources/user#user-object) field SHOULD be considered a primary key for our purposes.
18
+
A user of Grindcord SHOULD NOT be stored explicitly in our database. A [`GuildMember`](https://discord.com/developers/docs/resources/guild#guild-member-object) is an external dependency provided by Discord. A [`GuildMember`](https://discord.com/developers/docs/resources/guild#guild-member-object)'s `user_id` on the [`user`](https://discord.com/developers/docs/resources/user#user-object) field SHOULD be considered a primary key for our purposes.
19
19
20
-
A guild SHOULD NOT be stored explicitly in our database. A [`Guild`](https://discord.com/developers/docs/resources/guild#get-guild) is an external dependency provided by Discord. A `Guild`'s `guild_id` SHOULD be considered a primary key for our purposes.
20
+
A guild SHOULD NOT be stored explicitly in our database. A [`Guild`](https://discord.com/developers/docs/resources/guild#guild-object) is an external dependency provided by Discord. A `Guild`'s `guild_id` SHOULD be considered a primary key for our purposes.
21
21
22
22
```mermaid
23
23
erDiagram
24
-
direction LR
25
24
Guild
26
25
GuildMember
27
26
```
28
27
28
+
# Matches Played by Users
29
+
29
30
We split this into three tables.
30
31
31
32
```mermaid
@@ -52,30 +53,62 @@ erDiagram
52
53
53
54
##### Entity Relation Diagram for Matches, storing the data that would be reported by a user.
54
55
55
-
The winner of the match can be inferred by selecting the `MatchPlayer` record with the highest `win_count` among records with the same `match_id`.
56
+
The winner of the match SHALL be inferred by selecting the `MatchPlayer` record with the highest `win_count` among records with the same `match_id`.
56
57
57
58
Note that `guild_id` is not stored by the `Match` table. When a match is reported for a particular `guild_id` (a unique ID assigned by Discord for a particular Discord server), the match is reported for that "guild's" current season (see below).
58
59
60
+
# Seasons for Guilds
61
+
59
62
```mermaid
60
63
erDiagram
61
64
direction LR
62
65
Match {
63
-
int match_id
64
-
int season_id
66
+
int match_id PK
67
+
int season_id FK
65
68
datetime created_at
66
69
}
67
70
Season {
68
-
int season_id
71
+
int season_id PK
69
72
string guild_id
70
73
datetime start_at
71
74
datetime end_at
72
75
}
73
76
Match }|--|| Season: "was played during"
74
-
Guild ||--o{ Season: "has a current or past"
77
+
Guild ||--o{ Season: "has a"
75
78
```
76
79
77
80
##### Entity Relation Diagram for Seasons.
78
81
79
82
A guild's "current" season is a `Season` record for which the `guild_id` matches, and the system datetime is between `start_at` and `end_at`.
80
83
81
-
In addition, a `Season` in which participants will be designated an individual tier. Participants in a `Season` are `GuildMember` who report having participated in a `Match` during a `Season`.
84
+
> Queries for a guild's current season should be optimized by creating an index on a guild.
85
+
86
+
A `Match` is played in a `Season` if the `season_id` matches a `Season` record's `season_id`.
87
+
88
+
In addition, a `Season` in which participants will be designated an individual tier. Participants in a `Season` are `GuildMember`s who report having participated in a `Match` during a `Season`.
89
+
90
+
# Tiers for Users Playing Matches
91
+
92
+
> We recommand some in-memory key-value database to store tiers for current seasons. This is not implemented for the current release of Grindcord.
93
+
94
+
For past seasons, Grindcord SHALL keep a record of each participating user's role.
95
+
96
+
```mermaid
97
+
erDiagram
98
+
direction LR
99
+
UserSeasonTier {
100
+
string user_id PK
101
+
int season_id PK,FK
102
+
string tier_role_id
103
+
}
104
+
Season {
105
+
int season_id PK
106
+
string guild_id PK
107
+
datetime start_at
108
+
datetime end_at
109
+
}
110
+
UserSeasonTier ||..|| User: "assigns a tier to"
111
+
UserSeasonTier }|--|| Season: "determines tier in season"
112
+
```
113
+
114
+
A `tier_role_id` is the `role_id` of a role in a Discord server.
0 commit comments