-
-
Notifications
You must be signed in to change notification settings - Fork 777
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix hackathon list page loadtime (#7254)
* remove unused fields * refactor: load context from perftools.models.JSONStore * fix isort Co-authored-by: Dan Lipert <[email protected]>
- Loading branch information
1 parent
93ac742
commit 6bcbf73
Showing
6 changed files
with
146 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django import template | ||
from django.utils.formats import date_format | ||
|
||
import dateutil.parser | ||
|
||
|
||
register = template.Library() | ||
|
||
|
||
@register.filter(expects_localtime=True, is_safe=False) | ||
def date_fromisoformat(value, arg=None): | ||
"""Get datetime.datetime from isofromat string then use given format.""" | ||
|
||
if value in (None, ''): | ||
return '' | ||
try: | ||
return date_format(dateutil.parser.parse(value), arg) | ||
except AttributeError: | ||
try: | ||
return format(dateutil.parser.parse(value), arg) | ||
except AttributeError: | ||
return '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django import template | ||
from django.utils.timesince import timesince | ||
|
||
import dateutil.parser | ||
|
||
|
||
register = template.Library() | ||
|
||
|
||
@register.filter(is_safe=False) | ||
def timesince_fromisoformat(value, arg=None): | ||
"""Convert value to datetime.datetime object then format as timesince.""" | ||
|
||
if not value: | ||
return '' | ||
try: | ||
if arg: | ||
return timesince(dateutil.parser.parse(value), arg) | ||
return timesince(dateutil.parser.parse(value)) | ||
except (ValueError, TypeError): | ||
return '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters