Skip to content

Commit 161d607

Browse files
[GSoC] Updated Docs (#26)
* Added Leaderboard API documentation * Added Username Exists API documentation * Added Nearby Edits by a User API documentation * Added Uploads by a user API documentation * Added Used Images by a user API documentation * Leaderboard DB documentation * Fixed Image load * Update README.md * Update DB Schema folder * Update README.md * Update DB Schema * Update leaderboard.md * Updated Docs * Updated docs * Update leaderboard.md * Update leaderboard.md * Update leaderboard.md
1 parent 37aae43 commit 161d607

6 files changed

+152
-5
lines changed

API/nearby_by_user_and_duration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Nearby Edits by a User API
22

3-
This API is used to check if a username is valid or not.
3+
This API is used to get nearby edits by a user.
44

55
## Base URL
66
`https://tools.wmflabs.org/commons-android-app/tool-commons-android-app`

API/update_avatar.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Update Leaderboard Avatar API
22

3-
This API is used to check if a username is valid or not.
3+
This API is used to update a leaderboard user avatar.
44

55
## Base URL
66
`https://tools.wmflabs.org/commons-android-app/tool-commons-android-app`

API/update_leaderboard.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Update Leaderboard API
2+
3+
This API is used to update a leaderboard user data.
4+
5+
## Base URL
6+
`https://tools.wmflabs.org/commons-android-app/tool-commons-android-app`
7+
8+
## Endpoint
9+
`/update_leaderboard.py`
10+
11+
## Request Type
12+
`GET`
13+
14+
## Response Type
15+
`JSON`
16+
17+
## Required Parameters
18+
19+
- **user** - This is username of the user, for example **Syced** (if username has **whitespaces** then replace them with `_` )
20+
21+
22+
## Example Request
23+
24+
```
25+
curl --location --request GET 'https://commons-android-app.toolforge.org/tool-commons-android-app/update_leaderboard.py?user=Syced'
26+
```
27+
28+
## Example Responses
29+
30+
```
31+
{
32+
"status": "200",
33+
"message": "Data Updated",
34+
"user": "Syced"
35+
}
36+
```
37+
38+
**Note: Returns error if params are invalid**
39+
```
40+
{
41+
"status": "400",
42+
"message": "Invalid Parameters",
43+
"user": null
44+
}
45+
```

API/uploads_by_user_and_duration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Uploads by a User API
22

3-
This API is used to check if a username is valid or not.
3+
This API is used to get uploads by a user.
44

55
## Base URL
66
`https://tools.wmflabs.org/commons-android-app/tool-commons-android-app`

API/used_images_by_user_and_duration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Unique Used Images by a User API
22

3-
This API is used to check if a username is valid or not.
3+
This API is used to get unique used images by a user.
44

55
## Base URL
66
`https://tools.wmflabs.org/commons-android-app/tool-commons-android-app`

DB_Schema/leaderboard.md

+103-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ After that run the following commands
2525

2626
![show-tables](images/show-tables.png)
2727

28+
```
29+
MariaDB [s53794__leaderboard]> show tables;
30+
+-------------------------------+
31+
| Tables_in_s53794__leaderboard |
32+
+-------------------------------+
33+
| leaderboard_nearby |
34+
| leaderboard_upload |
35+
| leaderboard_used |
36+
| leaderboard_user |
37+
+-------------------------------+
38+
4 rows in set (0.01 sec)
39+
40+
```
41+
2842
- `> desc leaderboard_user;`
2943

3044
- `> desc leaderboard_used;`
@@ -35,6 +49,51 @@ After that run the following commands
3549

3650
![desc-tables](images/desc-tables.png)
3751

52+
```
53+
MariaDB [s53794__leaderboard]> desc leaderboard_user;
54+
+-------------+-----------------+------+-----+---------+----------------+
55+
| Field | Type | Null | Key | Default | Extra |
56+
+-------------+-----------------+------+-----+---------+----------------+
57+
| username | varbinary(255) | NO | UNI | NULL | |
58+
| user_id | int(5) unsigned | NO | PRI | NULL | auto_increment |
59+
| user_avatar | varchar(255) | NO | | NULL | |
60+
+-------------+-----------------+------+-----+---------+----------------+
61+
3 rows in set (0.00 sec)
62+
63+
MariaDB [s53794__leaderboard]> desc leaderboard_used;
64+
+----------+---------------------+------+-----+---------+-------+
65+
| Field | Type | Null | Key | Default | Extra |
66+
+----------+---------------------+------+-----+---------+-------+
67+
| user_id | int(5) unsigned | NO | MUL | NULL | |
68+
| weekly | bigint(20) unsigned | NO | | NULL | |
69+
| yearly | bigint(20) unsigned | NO | | NULL | |
70+
| all_time | bigint(20) unsigned | NO | | NULL | |
71+
+----------+---------------------+------+-----+---------+-------+
72+
4 rows in set (0.01 sec)
73+
74+
MariaDB [s53794__leaderboard]> desc leaderboard_upload;
75+
+----------+---------------------+------+-----+---------+-------+
76+
| Field | Type | Null | Key | Default | Extra |
77+
+----------+---------------------+------+-----+---------+-------+
78+
| user_id | int(5) unsigned | NO | MUL | NULL | |
79+
| weekly | bigint(20) unsigned | NO | | NULL | |
80+
| yearly | bigint(20) unsigned | NO | | NULL | |
81+
| all_time | bigint(20) unsigned | NO | | NULL | |
82+
+----------+---------------------+------+-----+---------+-------+
83+
4 rows in set (0.00 sec)
84+
85+
MariaDB [s53794__leaderboard]> desc leaderboard_nearby;
86+
+----------+---------------------+------+-----+---------+-------+
87+
| Field | Type | Null | Key | Default | Extra |
88+
+----------+---------------------+------+-----+---------+-------+
89+
| user_id | int(5) unsigned | NO | MUL | NULL | |
90+
| weekly | bigint(20) unsigned | NO | | NULL | |
91+
| yearly | bigint(20) unsigned | NO | | NULL | |
92+
| all_time | bigint(20) unsigned | NO | | NULL | |
93+
+----------+---------------------+------+-----+---------+-------+
94+
4 rows in set (0.00 sec)
95+
```
96+
3897
## Create Database
3998

4099
```
@@ -55,5 +114,48 @@ Note: make sure to use `__` double underscore
55114
## To Create Tables Run a SQL file like
56115

57116
```
58-
mysql -u root -p --no-data dbname > create_leaderboard_tables.sql
117+
$ cd scripts/create_leaderboard_tables
118+
$ mysql -u root -p --no-data dbname < create_leaderboard_tables.sql
119+
```
120+
121+
## Pull from Repo
122+
123+
```
124+
$ become commons-android-app
125+
126+
$ cd public_html/tool-commons-android-app
127+
128+
$ git pull origin master
129+
130+
```
131+
132+
## Create config.yaml
133+
134+
```
135+
$ nano config.yaml
136+
```
137+
138+
Example config.yaml file
139+
```
140+
DB_HOST: tools.db.svc.eqiad.wmflabs
141+
DB_USER: s53794
142+
DB_PASS: {your_password}
143+
DB_NAME: s53794__leaderboard
144+
```
145+
146+
## Start API Webservice
147+
148+
```
149+
$ webservice --backend=gridengine lighttpd start
150+
```
151+
152+
## Make Cron Job
153+
154+
```
155+
$ crontab -e
156+
```
157+
158+
Example cronjob to refresh leaderboard after every 2 hours
159+
```
160+
0 */2 * * * cd /data/project/commons-android-app/public_html/tool-commons-android-app/scripts/refresh_leaderboard && /usr/bin/jsub -N cron-29 -once -quiet -cwd /usr/bin/python3.5 refresh_leaderboard.py
59161
```

0 commit comments

Comments
 (0)