mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
Import users/plus data script
This commit is contained in:
parent
ad9ed1df56
commit
4e594490d1
|
|
@ -10,6 +10,7 @@
|
|||
"start": "npm run migrate up && remix-serve build",
|
||||
"migrate": "ley",
|
||||
"migrate:reset": "node scripts/delete-db-files.mjs && npm run migrate && npm run seed",
|
||||
"import-data": "node --experimental-specifier-resolution=node --loader ts-node/esm -r tsconfig-paths/register scripts/init-db-users-plus.ts",
|
||||
"seed": "node --experimental-specifier-resolution=node --loader ts-node/esm -r tsconfig-paths/register scripts/seed.ts",
|
||||
"seed:cypress": "cross-env NODE_ENV=test npm run seed",
|
||||
"lint:ts": "eslint . --ext .ts,.tsx",
|
||||
|
|
|
|||
34
scripts/init-db-users-plus.ts
Normal file
34
scripts/init-db-users-plus.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import users from "./users.json";
|
||||
import "dotenv/config";
|
||||
import { db } from "../app/db";
|
||||
|
||||
const usersWithPlusStatus = users.filter(
|
||||
(user) => user.plusStatus?.membershipTier
|
||||
);
|
||||
|
||||
for (const user of usersWithPlusStatus) {
|
||||
db.users.upsert({
|
||||
discordDiscriminator: user.discriminator,
|
||||
discordId: user.discordId,
|
||||
discordName: user.username,
|
||||
twitch: null,
|
||||
youtubeId: null,
|
||||
discordAvatar: user.discordAvatar,
|
||||
twitter: null,
|
||||
});
|
||||
}
|
||||
|
||||
const votes: any[] = [];
|
||||
for (const [i, user] of usersWithPlusStatus.entries()) {
|
||||
votes.push({
|
||||
authorId: 1,
|
||||
month: 5,
|
||||
year: 2022,
|
||||
score: 1,
|
||||
tier: user.plusStatus!.membershipTier,
|
||||
validAfter: new Date(),
|
||||
votedId: i + 1,
|
||||
});
|
||||
}
|
||||
|
||||
db.plusVotes.createMany(votes);
|
||||
112133
scripts/users.json
Normal file
112133
scripts/users.json
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user