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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add updated date field
  • Loading branch information
leo-step committed Jul 31, 2022
commit 4f3a0a6225618541d456dd5677dbd3104c1bfa98
6 changes: 4 additions & 2 deletions cron/update_questions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import requests
from urllib.parse import urlparse
from datetime import datetime
import json

query = '''query questionData($titleSlug: String!) {
Expand All @@ -16,7 +17,7 @@

print("Updating question metadata")

for question in questions:
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/

our_difficulty = question["difficulty"]
Expand All @@ -34,7 +35,8 @@

print("Finished checking all questions")

with open("questions.json", "w") as file:
with open("output.json", "w") as file:
questions["updated"] = str(datetime.now().isoformat())
json.dump(questions, file, indent=2)

print("Wrote questions file")
Loading