Skip to content

Commit 9707c94

Browse files
CopilotMishkatIT
andcommitted
Move MAX_REASONABLE_COUNT to class level constant
Co-authored-by: MishkatIT <125080003+MishkatIT@users.noreply.github.com>
1 parent 06b7acd commit 9707c94

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎update_stats.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class PlatformStats:
1717
"""Class to handle fetching statistics from different platforms."""
1818

1919
LAST_KNOWN_FILE = 'last_known_counts.json'
20+
MAX_REASONABLE_COUNT = 10000 # Maximum expected problem count for validation
2021

2122
def __init__(self):
2223
self.stats = {}
@@ -182,9 +183,6 @@ def get_atcoder(self):
182183

183184
def get_codechef(self):
184185
"""Fetch CodeChef statistics using web scraping."""
185-
# Maximum reasonable problem count to detect parsing errors
186-
MAX_REASONABLE_COUNT = 10000
187-
188186
try:
189187
url = "https://www.codechef.com/users/MishkatIT"
190188
html = self.fetch_url(url)
@@ -208,7 +206,7 @@ def get_codechef(self):
208206
if match:
209207
count = int(match.group(1))
210208
# Sanity check - CodeChef count should be reasonable
211-
if 0 < count < MAX_REASONABLE_COUNT:
209+
if 0 < count < self.MAX_REASONABLE_COUNT:
212210
return count
213211

214212
# If no pattern matched, save HTML for debugging (in verbose mode)

0 commit comments

Comments
 (0)