Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
zackkrida committed Sep 7, 2022
1 parent a6c959b commit f5b2080
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/catalog/api/constants/field_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

json_fields = [
"id",
"created_on",
"title",
"foreign_landing_url",
"url",
Expand Down
4 changes: 4 additions & 0 deletions api/catalog/api/controllers/search_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ def search(
# Route users to the same Elasticsearch worker node to reduce
# pagination inconsistencies and increase cache hits.
s = s.params(preference=str(ip), request_timeout=7)

# Sort by new
s = s.sort({"created_on": {"order": "desc"}})

# Paginate
start, end = _get_query_slice(s, page_size, page, filter_dead)
s = s[start:end]
Expand Down
5 changes: 5 additions & 0 deletions api/catalog/api/serializers/media_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ class Meta:
model = AbstractMedia
fields = [
"id",
"created_on",
"title",
"foreign_landing_url",
"url",
Expand Down Expand Up @@ -308,6 +309,10 @@ class Meta:
source="identifier",
)

created_on = serializers.DateField(
help_text="The timestamp of when the media was added to Openverse.",
)

tags = TagSerializer(
allow_null=True, # replaced with ``[]`` in ``to_representation`` below
many=True,
Expand Down

0 comments on commit f5b2080

Please sign in to comment.