Skip to content

Commit f638a6d

Browse files
committed
update tests for get_submissions for atcoder
1 parent 2786293 commit f638a6d

4 files changed

Lines changed: 32 additions & 29 deletions

File tree

modules/sites/hackerearth.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ def get_problem_details(**args):
175175
editorial_link = None
176176
else:
177177
soup = BeautifulSoup(response.text, "lxml")
178-
print "soup", soup
179178
tags = Profile.get_tags(soup)
180179
editorial_link = Profile.get_editorial_link(problem_link,
181180
soup,

modules/utilities.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ def push_influx_data(measurement, points, app_name="cron"):
6161
print "Can't connect to influxdb"
6262
return
6363

64+
# -----------------------------------------------------------------------------
65+
def get_problem_mappings(db_obj, table, fields):
66+
problems = db_obj(table).select(table[fields[0]], table[fields[1]])
67+
return dict([(x[fields[0]], x[fields[1]]) for x in problems])
68+
6469
# -----------------------------------------------------------------------------
6570
def is_stopstalk_admin(user_id):
6671
return user_id in STOPSTALK_ADMIN_USER_IDS

private/scripts/submissions.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,6 @@ def concurrent_submission_retrieval_handler(action, user_id, custom):
111111
elif action == "DEL":
112112
current.REDIS_CLIENT.delete(redis_key)
113113

114-
# ------------------------------------------------------------------------------
115-
def populate_uva_problems():
116-
global uva_problem_dict
117-
118-
ptable = uvadb.problem
119-
uvaproblems = uvadb(ptable).select(ptable.problem_id, ptable.title)
120-
uva_problem_dict = dict([(x.problem_id, x.title) for x in uvaproblems])
121-
122-
# ------------------------------------------------------------------------------
123-
def populate_atcoder_problems():
124-
global atcoder_problem_dict
125-
126-
aptable = db.atcoder_problems
127-
problems = db(aptable).select(aptable.problem_identifier, aptable.name)
128-
atcoder_problem_dict = dict([(x.problem_identifier, x.name) for x in problems])
129-
130114
# ------------------------------------------------------------------------------
131115
def flush_problem_stats():
132116

@@ -763,9 +747,13 @@ def codechef_new_retrievals():
763747
print "Invalid arguments"
764748
sys.exit()
765749

766-
populate_uva_problems()
767-
populate_atcoder_problems()
768-
750+
uva_problem_dict = utilities.get_problem_mappings(uvadb,
751+
uvadb.problem,
752+
["problem_id", "title"])
753+
atcoder_problem_dict = utilities.get_problem_mappings(db,
754+
db.atcoder_problems,
755+
["problem_identifier",
756+
"name"])
769757
links = db(ptable).select(ptable.id, ptable.link)
770758
for row in links:
771759
plink_to_id[row.link] = row.id

0 commit comments

Comments
 (0)