Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1018 from kawazrepos/modify-sql
Browse files Browse the repository at this point in the history
SQLミスってて新しい順に並ばなかったの修正した
  • Loading branch information
giginet committed Dec 26, 2015
2 parents f3686a0 + 6aa0869 commit d491a76
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/django-activities/activities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ def latests(self):
"""
qs = super().get_queryset()
qs = qs.raw(
'SELECT *, MAX(id) AS id FROM activities_activity GROUP BY '
'content_type_id, object_id ORDER BY id DESC'
'SELECT *, MAX(id) AS max_id FROM activities_activity GROUP BY '
'content_type_id, object_id HAVING id = max_id '
'ORDER BY id DESC'
)
qs.count = lambda: len(list(qs))
return qs
Expand Down

0 comments on commit d491a76

Please sign in to comment.