resolve #12
This commit is contained in:
parent
f08d1324d0
commit
6a18812e9d
16 changed files with 175 additions and 34 deletions
17
src/tools/calculate-all-rating.worker.ts
Normal file
17
src/tools/calculate-all-rating.worker.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { Users } from '../models';
|
||||
import { updateRating } from '../functions/update-rating';
|
||||
import { api } from '../services/misskey';
|
||||
import { MiUser } from '../functions/update-score';
|
||||
|
||||
export default async () => {
|
||||
const users = await Users.find();
|
||||
for (const u of users) {
|
||||
console.log(`Update rating of ${u.username}@${u.host}...`);
|
||||
const miUser = await api<MiUser & { error: unknown }>(u.host, 'users/show', { username: u.username }, u.token);
|
||||
if (miUser.error) {
|
||||
console.log(`Failed to fetch data of ${u.username}@${u.host}. Skipped`);
|
||||
continue;
|
||||
}
|
||||
await updateRating(u, miUser);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue