-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(admin): cron 유료로 클릭시 최신반영 플로우로 변경 (#173)
- Loading branch information
1 parent
c14a8e9
commit 9d56aa4
Showing
14 changed files
with
141 additions
and
95 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file added
BIN
+334 KB
.yarn/cache/@tanstack-react-query-npm-5.52.0-2024f6d138-6976d309d3.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 4 additions & 34 deletions
38
apps/admin/src/app/api/cron/current-applicant-count/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { NextResponse } from 'next/server'; | ||
|
||
import { updateCurrentApplicantCount } from '@/app/api/handler'; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
export const runtime = 'nodejs'; | ||
|
||
export async function PUT() { | ||
const currentApplicantCountForm = await updateCurrentApplicantCount(); | ||
|
||
return NextResponse.json(currentApplicantCountForm, { | ||
status: 200, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { put } from '@vercel/blob'; | ||
import { JWT } from 'google-auth-library'; | ||
import { GoogleSpreadsheet } from 'google-spreadsheet'; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const updateCurrentApplicantCount = async () => { | ||
const serviceAccountAuth = new JWT({ | ||
email: process.env.GOOGLE_CLIENT_EMAIL, | ||
key: process.env.GOOGLE_PRIVATE_KEY.replace(/\\n/g, '\n'), | ||
scopes: ['https://www.googleapis.com/auth/spreadsheets'], | ||
}); | ||
|
||
const developerApplicantDoc = new GoogleSpreadsheet('1LLxVCTkqtTZoMftrEkYOlwVdyEwoEKwCg7WvXwfW2Rk', serviceAccountAuth); | ||
const designerApplicantDoc = new GoogleSpreadsheet('1BToiD3gjzT-SKWeKnQMRuFvGXmYv44oEigSIJy_w1Jc', serviceAccountAuth); | ||
|
||
await developerApplicantDoc.loadInfo(); | ||
await designerApplicantDoc.loadInfo(); | ||
|
||
const developerApplicantRows = await developerApplicantDoc.sheetsByIndex[0].getRows(); | ||
const designerApplicantRows = await designerApplicantDoc.sheetsByIndex[0].getRows(); | ||
|
||
const currentApplicantCountForm = { | ||
developer: developerApplicantRows.length, | ||
designer: designerApplicantRows.length, | ||
}; | ||
|
||
const jsonString = JSON.stringify(currentApplicantCountForm); | ||
|
||
const requestBlob = new Blob([jsonString], { type: 'application/json' }); | ||
|
||
await put('current_applicant_count.json', requestBlob, { | ||
access: 'public', | ||
token: process.env.DND_ACADEMY_V2_BLOB_READ_WRITE_TOKEN, | ||
addRandomSuffix: false, | ||
cacheControlMaxAge: 3600, | ||
}); | ||
|
||
return currentApplicantCountForm; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
...rrentApplicantCountForm/index.module.scss → ...entApplicantCountAction/index.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
apps/admin/src/components/CurrentApplicantCountAction/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use client'; | ||
|
||
import { api, type CurrentApplicantCount } from '@dnd-academy/core'; | ||
import { Button } from '@dnd-academy/ui'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import clsx from 'clsx'; | ||
|
||
import styles from './index.module.scss'; | ||
|
||
function CurrentApplicantCountAction() { | ||
const { mutate, isSuccess } = useMutation({ | ||
mutationFn: async () => { | ||
await api<CurrentApplicantCount>({ | ||
url: '/current-applicant-count', | ||
method: 'PUT', | ||
type: 'bff', | ||
}); | ||
}, | ||
}); | ||
|
||
return ( | ||
<div className={styles.applicantCountWrapper}> | ||
<Button onClick={() => mutate()}>최신 지원자수 반영하기</Button> | ||
{isSuccess && ( | ||
<div className={clsx(styles.message, styles.success)}>지원자수가 최신으로 업데이트 되었습니다.</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default CurrentApplicantCountAction; |
50 changes: 0 additions & 50 deletions
50
apps/admin/src/components/CurrentApplicantCountForm/index.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use client'; | ||
|
||
import { PropsWithChildren } from 'react'; | ||
|
||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
|
||
const queryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
retry: false, | ||
refetchOnWindowFocus: false, | ||
}, | ||
}, | ||
}); | ||
|
||
function ClientProvider({ children }: PropsWithChildren) { | ||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
{children} | ||
</QueryClientProvider> | ||
); | ||
} | ||
|
||
export default ClientProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"crons": [{ | ||
"path": "/api/cron/current-applicant-count", | ||
"schedule": "0 * * * *" | ||
"schedule": "0 0 * * *" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters