Skip to content

Commit

Permalink
Use published date for discovery features
Browse files Browse the repository at this point in the history
  • Loading branch information
dcwatson committed May 4, 2024
1 parent 62ee392 commit f4344c1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions activities/models/hashtag.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ def popular(cls, days=7, limit=20, offset=None) -> list["Hashtag"]:
sql = """
SELECT jsonb_array_elements_text(hashtags) AS tag, count(id) AS uses
FROM activities_post
WHERE state NOT IN ('deleted', 'deleted_fanned_out') AND
created::date >= %s
WHERE state NOT IN ('deleted', 'deleted_fanned_out') AND published >= %s
GROUP BY tag
ORDER BY uses DESC
LIMIT %s
Expand Down
2 changes: 1 addition & 1 deletion activities/services/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def hashtag(self, hashtag: str | Hashtag) -> models.QuerySet[Post]:
.public()
.filter(author__restriction=Identity.Restriction.none)
.tagged_with(hashtag)
.order_by("-id")
.order_by("-published")
)

def notifications(self, types: list[str]) -> models.QuerySet[TimelineEvent]:
Expand Down
4 changes: 2 additions & 2 deletions api/views/trends.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def trends_statuses(
posts = (
Post.objects.not_hidden()
.visible_to(request.identity)
.filter(created__gte=since)
.filter(published__gte=since)
.annotate(num_interactions=Count("interactions"))
.order_by("-num_interactions", "-created")[offset : offset + limit]
.order_by("-num_interactions", "-published")[offset : offset + limit]
)
return schemas.Status.map_from_post(list(posts), request.identity)

Expand Down

0 comments on commit f4344c1

Please sign in to comment.