Refactor is_outdated properties for consistent boolean return#188
Refactor is_outdated properties for consistent boolean return#188sujalsom22 wants to merge 1 commit intoOpenLake:mainfrom
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.Unrecognized words (592)Some files were automatically ignored 🙈These sample patterns would exclude them: You should consider excluding directory paths (e.g. You should consider adding them to: File matching is via Perl regular expressions. To check these files, more of their words need to be in the dictionary than not. You can use To accept these unrecognized words as correct and update file exclusions, you could run the following commands... in a clone of the git@github.com:sujalsom22/Leaderboard-Pro.git repository curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/OpenLake/Leaderboard-Pro/actions/runs/21924100548/attempts/1' &&
git commit -m 'Update check-spelling metadata'Available 📚 dictionaries could cover words not in the 📘 dictionary
Consider adding them (in with:
extra_dictionaries: |
cspell:django/dict/django.txt
cspell:software-terms/dict/softwareTerms.txt
cspell:python/src/common/extra.txt
cspell:npm/dict/npm.txt
cspell:fullstack/dict/fullstack.txtTo stop checking additional dictionaries, add (in check_extra_dictionaries: ""Warnings
|
| Count | |
|---|---|
| 15 | |
| 1 | |
| 4 | |
| 10 |
See
If you see a bunch of garbage
If it relates to a ...
well-formed pattern
See if there's a pattern that would match it.
If not, try writing one and adding it to the patterns.txt file.
Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
binary-ish string
Please add a file path to the excludes.txt file instead of just accepting the garbage.
File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
api/leaderboard/models.py (1)
48-48:⚠️ Potential issue | 🟠 MajorPre-existing bug:
defaultis evaluated once at class-definition time.
default=datetime.now().timestamp()is evaluated when the module loads, so every newcodeforcesUserinstance gets the same stale timestamp. This should use a callable instead.🐛 Suggested fix
- last_activity = models.BigIntegerField(default=datetime.now().timestamp()) + last_activity = models.BigIntegerField(default=0)Or if a dynamic default is intended:
def _default_timestamp(): return int(datetime.now(tz=timezone.utc).timestamp()) # then in the model: last_activity = models.BigIntegerField(default=_default_timestamp)
🧹 Nitpick comments (1)
api/leaderboard/models.py (1)
22-22: Optional: preferdjango.utils.timezone.now()overdatetime.now(tz=timezone.utc).Django's
timezone.now()respects theUSE_TZsetting and is the idiomatic choice in Django projects. This is a pre-existing pattern, so fine to defer.♻️ Example
-from datetime import datetime, timedelta, timezone +from datetime import timedelta + +from django.utils import timezoneThen in each property:
- return datetime.now(tz=timezone.utc) - self.last_updated > timedelta(minutes=1) + return timezone.now() - self.last_updated > timedelta(minutes=1)Also applies to: 35-35, 56-56, 120-120
Description
Refactor is_outdated properties for consistent boolean return
Problem
Several
is_outdatedproperties returnedNonewhen the condition was false due to usingelse: Falsewithout an explicit return statement.Solution
Refactored all
is_outdatedmethods to directly return the boolean expression:return datetime.now(tz=timezone.utc) - self.last_updated > timedelta(minutes=X)
Impact
Summary by CodeRabbit