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

Commit 6845b0b

Browse files
Correct absolute path for run-cron GitHub Action (#208)
* Correct absolute path for run-cron GitHub Action Fixes #207 * Correct commit message for updating questions
1 parent fe1e89e commit 6845b0b

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

‎.github/workflows/run-cron.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
python cron/update_questions.py
2323
- uses: stefanzweifel/git-auto-commit-action@v4
2424
with:
25-
commit_message: update questions (cron job)
25+
commit_message: Update questions via run-cron GitHub Action

‎cron/update_questions.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import os
2+
import json
13
import requests
24
from datetime import datetime
3-
import json
45

56
query = '''query questionData($titleSlug: String!) {
67
question(titleSlug: $titleSlug) {
@@ -9,9 +10,9 @@
910
}
1011
'''
1112

12-
questions_file = "../src/data/questions.json"
13+
questions_file = os.getcwd() +"/src/data/questions.json"
1314

14-
print("Reading questions file")
15+
print("=== Reading questions file ===")
1516

1617
try:
1718
with open(questions_file, "r") as file:
@@ -20,7 +21,9 @@
2021
print(e)
2122
exit()
2223

23-
print("Updating question metadata")
24+
print("=== Updating question metadata ===")
25+
26+
startTime = datetime.now()
2427

2528
for question in questions["data"]:
2629
variables = {"titleSlug": question["url"]}
@@ -36,7 +39,7 @@
3639
print(f'{question["name"]}: {our_difficulty} -> {leetcode_difficulty}')
3740
question["difficulty"] = leetcode_difficulty
3841

39-
print("Finished checking all questions")
42+
print("=== Finished checking all questions ===")
4043

4144
try:
4245
with open(questions_file, "w") as file:
@@ -46,4 +49,5 @@
4649
print(e)
4750
exit()
4851

49-
print("Wrote questions file")
52+
print("=== Wrote questions file ===")
53+
print(f'=== Script took: {datetime.now() - startTime} seconds ===')

0 commit comments

Comments
(0)

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