Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use questions json and run cron #206

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

Merged
seanprashad merged 2 commits into seanprashad:master from leo-step:use-questions-json
Aug 2, 2022

Conversation

Copy link
Contributor

@leo-step leo-step commented Aug 2, 2022

  • Read & display data directly from questions.json instead of overwriting src/data/index.js
  • Run cron job every Sunday at 5pm PST to automatically update question metadata

Copy link
Contributor Author

leo-step commented Aug 2, 2022

Next up is checking companies and using "updated" field in questions.json as value for tooltip.

seanprashad reacted with hooray emoji

Copy link
Owner

@seanprashad seanprashad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @leo-step - you're on a roll!! 👏🏽

on: workflow_dispatch
on:
schedule:
- cron: '0 0 * * 0'
Copy link
Owner

@seanprashad seanprashad Aug 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference, 00:00 UTC is 8:00pm EDT/5:00pm PDT:

Screenshot 2022年08月01日 at 10 26 56 PM

See https://crontab.guru/#0_0_*_*_0

const url = cellInfo.row.original.premium
? `${cellInfo.row.original.url}/`
: cellInfo.row.original.url;
const url = `https://leetcode.com/problems/${cellInfo.row.original.url}/`;
Copy link
Owner

@seanprashad seanprashad Aug 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update here - I'm trying to remember why I had this conditional in the first place.. so weird 😅

leo-step reacted with laugh emoji
@seanprashad seanprashad merged commit fe1e89e into seanprashad:master Aug 2, 2022
Copy link
Owner

seanprashad commented Aug 2, 2022
edited
Loading

Next up is checking companies and using "updated" field in questions.json as value for tooltip.

Makes sense to me! In order to grab the list of companies, we'll need to authenticate via the regular /login API path, retrieve the session token, and pass that in the payload with the GraphQL queries. I might be wrong, but that's how I'm thinking we should tackle it - we can leverage other great repos like https://github.com/realvect0r/leetcode-api/blob/32b5658fd8e5c27ebddfe7f1198218e9e13be64e/src/lib/leetcode.ts#L35 if that's easier

Edit: I think there is where we'll need to add a username and password as secrets in GitHub so our Python script grab the username/password like SECRETS.USERNAME and SECRETS.PASSWORD. You can set them as env variables locally but be double check not to commit them when the time comes to open your PR!

USERNAME=leo PASSWORD=step python3 cron/update_questions.py

Edit 2: I've added LEETCODE_USERNAME and LEETCODE_PASSWORD as repository secrets that we can use in our GitHub Workflow later on!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@seanprashad seanprashad seanprashad approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /