Skip to content

Commit

Permalink
November 2024 Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kraust committed Nov 29, 2024
1 parent ed76344 commit f802621
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 7 additions & 1 deletion combatlog/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" CombatLog admin """
"""CombatLog admin"""

from django.contrib import admin
from django.db.models import JSONField
Expand All @@ -14,3 +14,9 @@ class MetadataAdmin(admin.ModelAdmin):
formfield_overrides = {
JSONField: {"widget": JSONEditorWidget},
}


@admin.register(CombatLog)
class CombatLogAdmin(admin.ModelAdmin):
inlines = [LadderEntryInline]
exclude = ["metadata"]
15 changes: 4 additions & 11 deletions combatlog/models/combatlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,8 @@ def update_metadata_file(self, file, force=False):
if len(players) == 0:
raise APIException("Combat log is empty")

# Grab the highest combat_time. This is used to validate other players.
# If Time < 30s: Combat Time should be within 50%
# If Time >= 30s and < 60s: Combat Time should be within 75%
# If Time >= 60s: Combat Time should be within 90% of the highbest.
if players[0][1]["combat_time"] < 60:
combat_time = players[0][1]["combat_time"] * 0.75
elif players[0][1]["combat_time"] < 30:
combat_time = players[0][1]["combat_time"] * 0.50
else:
combat_time = players[0][1]["combat_time"] * 0.90
# TBD: We use 0.9 combat time until a better choice can be made.
combat_time = players[0][1]["combat_time"] * 0.90

# Check to see if map / difficulty combination exists in the ladder
# table. if it does, iterate over each player to see if they have a
Expand Down Expand Up @@ -276,8 +268,9 @@ def update_metadata_file(self, file, force=False):
if result["updated"]:
updated += 1

# No not raise an exception here anymore - return the status indicating why no logs were updated.
if updated == 0 and not force:
raise APIException("There are no new records in this combat log.")
return results

with transaction.atomic():
if self.metadata is None:
Expand Down
1 change: 1 addition & 0 deletions ladder/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

@admin.register(LadderEntry)
class LadderEntryAdmin(admin.ModelAdmin):
exclude = [ "combatlog" ]
list_display = [
"player",
"ladder__name",
Expand Down

0 comments on commit f802621

Please sign in to comment.