Skip to content

Commit

Permalink
fix(ci): use circleci to run update-club-info
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerzl committed Sep 18, 2024
1 parent b63c4c1 commit b04dc04
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 34 deletions.
33 changes: 33 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: 2.1

jobs:
update-club-info:
docker:
- image: node:18
resource_class: large
parallelism: 10

steps:
- checkout
- restore_cache:
name: Restore pnpm Package Cache
keys:
- pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
- run:
name: Install pnpm package manager
command: |
corepack enable
corepack prepare pnpm@latest-9 --activate
pnpm config set store-dir .pnpm-store
- run:
name: Install Dependencies
command: |
pnpm install
- save_cache:
name: Save pnpm Package Cache
key: pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
paths:
- .pnpm-store
- run:
name: Update Club Info
command: pnpm run update-club-info
33 changes: 0 additions & 33 deletions netlify/functions/update-club-info-background.mts

This file was deleted.

7 changes: 6 additions & 1 deletion utils/update-club-info.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { ClubMemberRole } from '@prisma/client'
import { getStore } from '@netlify/blobs'
import { PrismaClient } from '@prisma/client'
import type { Clubs } from '~/types/clubs'
import crawler from './crawler'

const prisma = new PrismaClient()
const clubs: Clubs = await crawler() as Clubs

interface ClubMembership {
tsimsStudentId: number
Expand All @@ -16,6 +16,8 @@ interface ClubMembership {
const categories: (keyof Clubs)[] = ['Sports', 'Service', 'Arts', 'Life', 'Academic']

export default async function main() {
const clubs = await crawler() as Clubs

const runSequence = []
for (const category of categories) {
const categoryClubs = clubs[category]
Expand Down Expand Up @@ -128,6 +130,9 @@ export default async function main() {
console.log(`start transaction with length ${runSequence.length}`)
await prisma.$transaction(runSequence)

const store = getStore('enspire')
await store.setJSON('clubs', clubs)

return clubs
}

Expand Down

0 comments on commit b04dc04

Please sign in to comment.