Skip to content

Commit

Permalink
script for tmp user creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mluukkai committed Sep 26, 2024
1 parent c7728a7 commit a64ed7b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 59 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ jobs:
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}

#- name: Run your tests
# env:
# CI: true
# run: npx playwright test
- name: Run your tests
env:
CI: true
run: npx playwright test

- name: Build staging image
id: build-staging-image
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"lint": "eslint 'src/**/*.ts'",
"format": "prettier --write '*.{ts,json,css,md}'",
"build": "vite build",
"prepare": "husky install"
"prepare": "husky install",
"tmpusers": "nodemon --exec node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm src/server/updater/tmpUsers.ts"
},
"repository": {
"type": "git",
Expand Down
54 changes: 0 additions & 54 deletions src/server/db/migrations/20242606_00_tmp_users_to_course.ts

This file was deleted.

60 changes: 60 additions & 0 deletions src/server/updater/tmpUsers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Enrolment, User } from '../db/models'

const run = async () => {
console.log('Creating tmp users')
const tmpAccounts = [
'4k117746',
'4k117747',
'4k117748',
'4k117749',
'4k117750',
'4k117751',
'4k117752',
'4k117753',
'4k117754',
'4k117755',
'4k117756',
'4k117757',
'4k117758',
'4k117759',
'4k117760',
'4k117761',
'4k117762',
'4k117763',
'4k117764',
'4k117765',
'4k117766',
'4k117767',
'4k117768',
'4k117769',
]

const chatInstanceId = '16d246ca-f9a5-4bf3-9d6e-824b261193df'
const userPromises = tmpAccounts.map((userId) => {
const user = {
id: userId,
username: userId,
lastName: userId,
}
return User.upsert(user)
})

const users = await Promise.all(userPromises)

console.log(JSON.stringify(users, null, 2))

const enrolmentPromises = tmpAccounts.map((userId) => {
const enrolment = {
userId,
chatInstanceId,
}
return Enrolment.upsert(enrolment)
})

const enrollments = await Promise.all(enrolmentPromises)

console.log(JSON.stringify(enrollments, null, 2))
console.log('Created tmp users')
}

run()

0 comments on commit a64ed7b

Please sign in to comment.