Skip to content

Commit b04dc04

Browse files
committed
fix(ci): use circleci to run update-club-info
1 parent b63c4c1 commit b04dc04

File tree

3 files changed

+39
-34
lines changed

3 files changed

+39
-34
lines changed

.circleci/config.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: 2.1
2+
3+
jobs:
4+
update-club-info:
5+
docker:
6+
- image: node:18
7+
resource_class: large
8+
parallelism: 10
9+
10+
steps:
11+
- checkout
12+
- restore_cache:
13+
name: Restore pnpm Package Cache
14+
keys:
15+
- pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
16+
- run:
17+
name: Install pnpm package manager
18+
command: |
19+
corepack enable
20+
corepack prepare pnpm@latest-9 --activate
21+
pnpm config set store-dir .pnpm-store
22+
- run:
23+
name: Install Dependencies
24+
command: |
25+
pnpm install
26+
- save_cache:
27+
name: Save pnpm Package Cache
28+
key: pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
29+
paths:
30+
- .pnpm-store
31+
- run:
32+
name: Update Club Info
33+
command: pnpm run update-club-info

netlify/functions/update-club-info-background.mts

Lines changed: 0 additions & 33 deletions
This file was deleted.

utils/update-club-info.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { ClubMemberRole } from '@prisma/client'
2+
import { getStore } from '@netlify/blobs'
23
import { PrismaClient } from '@prisma/client'
34
import type { Clubs } from '~/types/clubs'
45
import crawler from './crawler'
56

67
const prisma = new PrismaClient()
7-
const clubs: Clubs = await crawler() as Clubs
88

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

1818
export default async function main() {
19+
const clubs = await crawler() as Clubs
20+
1921
const runSequence = []
2022
for (const category of categories) {
2123
const categoryClubs = clubs[category]
@@ -128,6 +130,9 @@ export default async function main() {
128130
console.log(`start transaction with length ${runSequence.length}`)
129131
await prisma.$transaction(runSequence)
130132

133+
const store = getStore('enspire')
134+
await store.setJSON('clubs', clubs)
135+
131136
return clubs
132137
}
133138

0 commit comments

Comments
 (0)