Browse Source

adding description for each query

content-update
lee 2 years ago
parent
commit
83395eb179
  1. 21
      docs/db/sql.md

21
docs/db/sql.md

@ -1,9 +1,10 @@
## Example of SQL queries
### sign up export
### sign up
The following query returns the users that are currently in the sign up process.
```sql
-- query for **SINGUP**
SELECT DISTINCT
u.id,
u."githubLogin",
@ -17,7 +18,9 @@ WHERE u.id NOT IN (SELECT "userId" FROM public.user_role)
AND u.id NOT IN (SELECT "userId" FROM public.progress p WHERE p."userId"=u.id);
```
### Toad export
### Toad
The following query returns the users that are currently in the toad process. The information includes user and games info
```sql
-- query for **TOAD**
@ -50,7 +53,9 @@ AND r.attrs ->> 'games' IS NOT NULL
ORDER BY r.attrs ->> 'score' ASC;
```
### Administration export
### Administration
The following query returns the users currently in the administration process. All information about the user, the number of attempts and current phase.
```sql
-- query for **administration**
@ -97,9 +102,9 @@ GROUP BY u.id, r.attrs;
### xp per user per activity
The following query returns the amount of xp per user and per activity
```sql
-- user | xp | last activity : with parent association, "this may be stupid to put the path alrady as the parent!"
WITH xp_user AS (
SELECT
u."githubLogin",
@ -122,6 +127,8 @@ LEFT JOIN public.event e ON e.id=xu."eventParentId";
### user per xp
The following query returns the amount of xp per user
```sql
-- user per xp
SELECT
@ -147,6 +154,8 @@ ORDER BY xp.amount DESC;
### group status
The following query returns the groups status per captain
```sql
-- group status
SELECT
@ -160,6 +169,8 @@ ORDER BY u."githubLogin" ASC;
### group progresses
The following query returns the progress per group
```sql
-- group progresses
WITH progress_group AS (

Loading…
Cancel
Save