-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
783 backend write a cron job to automatically update a google sheet with the members #791
783 backend write a cron job to automatically update a google sheet with the members #791
Conversation
Draft PR. * Created new cron job(note that the cron is currently disabled and has workflow-dispatch for now). * Created `update-google-sheet-members.ts` script that current just fetches all users.
* Create `fetchUsers` method that fetches users from the backend * Create `getAllUsers` that fetches all the users from the backend using `fetchUsers` * Create `authenticateGoogle` method that returns a google auth client * Note that documentation will come soon... * Create `appendToGoogleSheet` and `clearSheet` * `appendToGoogleSheet` takes in the logs and auth client and updates the google sheet rows * `clearSheet` clears the google sheet so that `appendToGoogleSheet` doesn't overlap everything Note that the logic is still somewhat rough and could have improvements. Quite a lot of duplicate code and possibly better ways to update the google sheet instead of just appending and clearing every time.
Visit the preview URL for this PR (updated for commit 3cbb246): https://uasc-ceebc--pr791-783-backend-write-a-qbsu1xfl.web.app (expires Sat, 12 Oct 2024 10:31:27 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 36296ceaed1d43e92e7d5e81a72a7bd987560bfa |
* Now creates admin jwt with a function internally instead of with the actions script. * Moved all logic into an asynchronous function * Update date time formatting to a more readable format.
Used SHEET_ID before and apparently thats a different thing
Added some documentation in here: https://github.com/UoaWDCC/uasc-web/wiki/Deployment-Information#google-sheet-members-action |
* Uses NEXT instead of old VITE but references to VITE due to secrets not updated in github. * Updated env to include both `SHEET_ID` and `SPREADSHEET_ID`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tested the function by running ts-node
locally?
…lly-update-a-google-sheet-with-the-members
Still semi-draft...
*. Update dependencies in server workspace
package.json
fetchUsers
method that fetches users from the backendgetAllUsers
that fetches all the users from the backend usingfetchUsers
authenticateGoogle
method that returns a google auth clientappendToGoogleSheet
andclearSheet
appendToGoogleSheet
takes in the logs and auth client and updates the google sheet rowsclearSheet
clears the google sheet so thatappendToGoogleSheet
doesn't overlap everythingNote
The logic is still somewhat rough and could have improvements. Quite a lot of duplicate code and possibly better ways to update the google sheet instead of just appending and clearing every time.