diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..2aa6700 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + db: + image: postgres:17 + environment: + POSTGRES_PASSWORD: postgres + volumes: + - /data/postgres/wynn:/var/lib/postgresql/data + ports: + - 54327:5432 + +volumes: + pgdata: diff --git a/ts/docker-compose.yaml b/ts/docker-compose.yaml deleted file mode 100644 index 4081538..0000000 --- a/ts/docker-compose.yaml +++ /dev/null @@ -1,9 +0,0 @@ -version: '3' -services: - db: - image: postgres - restart: always - environment: - POSTGRES_PASSWORD: postgres - ports: - - 54327:5432 diff --git a/ts/src/activities/players.ts b/ts/src/activities/players.ts index 8b38dbb..862a197 100644 --- a/ts/src/activities/players.ts +++ b/ts/src/activities/players.ts @@ -20,11 +20,11 @@ const playerSchema = playerSchemaFail.or(playerSchemaSuccess) const getUUIDForUsername = async (username: string) => { const resp = await axios.get(`https://api.mojang.com/users/profiles/minecraft/${username}`, { validateStatus: function (status) { - return status < 500; + return status < 300 && status >= 200; }, }) if (resp.headers['content-type'] !== 'application/json') { - throw new Error('invalid content type') + throw new Error(`invalid content type: ${resp.headers['content-type']}`) } log.info('response data', {data: resp.data}) const parsed = playerSchema.assert(resp.data) diff --git a/ts/src/cmd/worker.ts b/ts/src/cmd/worker.ts index aaf08e2..ec1a7ab 100644 --- a/ts/src/cmd/worker.ts +++ b/ts/src/cmd/worker.ts @@ -8,7 +8,7 @@ import path from 'node:path' import { Client, ScheduleNotFoundError, type ScheduleOptions, ScheduleOverlapPolicy } from '@temporalio/client' import { NativeConnection, Worker, Runtime } from '@temporalio/worker' import { PG } from '#/services/pg' -import { workflowSyncAllGuilds, workflowSyncGuildLeaderboardInfo, workflowSyncGuilds, workflowSyncOnline } from '#/workflows' +import { workflowSyncAllGuilds, workflowSyncGuildLeaderboardInfo, workflowSyncGuilds, workflowSyncOnline, workflowSyncItemDatabase } from '#/workflows' import * as activities from '../activities' import { config } from '#/config' @@ -87,6 +87,24 @@ const schedules: ScheduleOptions[] = [ ], }, }, + { + scheduleId: 'update-wynn-items', + action: { + type: 'startWorkflow', + workflowType: workflowSyncItemDatabase, + taskQueue: 'wynn-worker-ts', + }, + policies: { + overlap: ScheduleOverlapPolicy.SKIP, + }, + spec: { + intervals: [ + { + every: '4 hours', + }, + ], + }, + }, ] const addSchedules = async (c: Client) => {