|
@@ -0,0 +1,19 @@
|
|
|
+import {osu_fetch} from '../api.js';
|
|
|
+import db from '../database.js';
|
|
|
+
|
|
|
+async function populate_flags() {
|
|
|
+ for (let i = 0; i < 4; i++) {
|
|
|
+ const top50 = db.prepare(`SELECT user_id FROM rating ORDER BY elo DESC LIMIT 50`).all();
|
|
|
+ const idlist = [];
|
|
|
+ for (let j = 0; j < 50; j++) {
|
|
|
+ idlist.push(`ids[${j}]=${top50[j].user_id}`);
|
|
|
+ }
|
|
|
+
|
|
|
+ const res = await osu_fetch(`https://osu.ppy.sh/api/v2/users?${idlist.join('&')}`);
|
|
|
+ for (const user of res.users) {
|
|
|
+ db.prepare(`UPDATE user SET profile_data = ?, country_code = ? WHERE user_id = ?`).run(JSON.stringify(user), user.country_code, user.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+populate_flags();
|