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

Generated updated questions json and commit #205

Merged
merged 7 commits into from
Aug 1, 2022

Conversation

leo-step
Copy link
Contributor

  • Store question data in json format
  • Cron job script reads and updates questions json
  • Sets "updated" field to current datetime
  • Commits the changes back into the repository

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.

You're on a roll @leo-step! Thank you once again for helping implement this - I know it'll definitely be appreciated by others for sure.

Everything is looking good - I think we should handle the case where questions.json isn't able to be opened/read.


print("Updating question metadata")

for question in questions["data"]:
p = urlparse(question["url"])
title_slug = p.path.rstrip('/').split('/')[-1]
Copy link
Owner

Choose a reason for hiding this comment

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

I think that it probably makes more sense to just have the slug for url since each URL is prefixed with https://leetcode.com/problems/

for question in questions:
print("Reading questions file")

with open("questions.json", "r") as file:
Copy link
Owner

Choose a reason for hiding this comment

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

I think it makes sense to have an except clause incase questions.json can't be opened/found

@@ -23,5 +31,12 @@

if their_difficulty != our_difficulty:
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if their_difficulty != our_difficulty:
if leetcode_difficulty != our_difficulty:

Could we make this small change here and in other relevant places? I think it'll help make reading the code a little easier!

@seanprashad seanprashad merged commit c1e33db into seanprashad:master Aug 1, 2022
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.

None yet

2 participants