Skip to content

Commit

Permalink
Merge pull request #223 from stanfordnmbl/dev-cleanup-processed-fields
Browse files Browse the repository at this point in the history
dev: reduce processed fields clutter in list view
  • Loading branch information
carmichaelong authored Oct 3, 2024
2 parents 32d72bd + 4462afe commit 7ad7565
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion mcserver/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from django.contrib.auth.models import Group
from django.contrib.auth.admin import UserAdmin, GroupAdmin
from django.contrib.admin.models import LogEntry
from datetime import timedelta


#admin.site.unregister(Group)
Expand Down Expand Up @@ -102,7 +103,7 @@ class TrialAdmin(admin.ModelAdmin):
'status',
'created_at', 'updated_at',
'server', 'git_commit',
'processed_duration', 'processed_count',
'formatted_duration', 'processed_count',
'is_meta_null',
'trashed', 'trashed_at',
)
Expand All @@ -112,6 +113,20 @@ class TrialAdmin(admin.ModelAdmin):
def is_meta_null(self, obj):
return obj.meta is None

def formatted_duration(self, obj):
if obj.processed_duration:
hours, remainder = divmod(int(obj.processed_duration.total_seconds()), 3600)
minutes, seconds = divmod(remainder, 60)
return f"{hours:02}:{minutes:02}:{seconds:02}"
else:
return obj.processed_duration

def processed_count(self, obj):
return obj.processed_count

formatted_duration.short_description = 'duration'
processed_count.short_description = 'count'


@admin.register(Result)
class ResultAdmin(admin.ModelAdmin):
Expand Down

0 comments on commit 7ad7565

Please sign in to comment.