Skip to content
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

Conversation

jeffplays2005
Copy link
Contributor

Still semi-draft...

*. Update dependencies in server workspace

  • Create new script in package.json
  • Created new cron job(note that the cron is currently disabled and has workflow-dispatch for now).
  • 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

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.

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.
Copy link

github-actions bot commented Oct 4, 2024

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

server/package.json Outdated Show resolved Hide resolved
server/tooling/update-google-sheet-members.ts Outdated Show resolved Hide resolved
server/tooling/update-google-sheet-members.ts Outdated Show resolved Hide resolved
* 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
@jeffplays2005
Copy link
Contributor Author

* 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`.
Copy link
Member

@choden-dev choden-dev left a 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?

server/tooling/update-google-sheet-members.ts Show resolved Hide resolved
@jeffplays2005
Copy link
Contributor Author

jeffplays2005 commented Oct 5, 2024

have you tested the function by running ts-node locally?

do we fetch all users and not check if they're members?

image image

@jeffplays2005
Copy link
Contributor Author

For documentation in this branch:

Updated secrets

Screenshot 2024-10-05 at 11 31 35 PM

@jeffplays2005 jeffplays2005 merged commit fc82826 into master Oct 5, 2024
8 checks passed
@jeffplays2005 jeffplays2005 deleted the 783-backend-write-a-cron-job-to-automatically-update-a-google-sheet-with-the-members branch October 5, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BACKEND] Write a cron job to automatically update a google sheet with the members
2 participants