This repository was archived by the owner on Apr 7, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed
Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -132,4 +132,4 @@ <h6 class="card-subtitle mb-2 text-muted">
132132
133133 </ div >
134134 </ div >
135- {% endblock %}
135+ {% endblock %}
Original file line number Diff line number Diff line change 11# Third party
2- from bugboard .models import Project , Task
3- from django .db .models import Max
2+ from bugboard .models import Project , Task , Comment
3+ from django .db .models import Max , Subquery , OuterRef
44from django .views import generic
55
66
@@ -46,10 +46,16 @@ class CommentedView(generic.ListView):
4646 template_name = "bugboard/task_list.html"
4747 paginate_by = 100
4848
49+ # Thanks https://docs.djangoproject.com/fr/2.2/ref/models/expressions/#subquery-expressions
50+ newest = Comment .objects .filter (task = OuterRef ('pk' )).order_by ('-created_at' )
51+
4952 queryset = (
50- Task .objects .exclude (comment = None )
51- .annotate (last_com = Max ("comment__created_at" ))
52- .order_by ("-last_com" )
53+ Task .objects
54+ .exclude (comment = None ) # exclude tasks with no comments
55+ .annotate (last_com = Max ("comment__created_at" )) # add last com in queryset
56+ .annotate (last_comment_member = Subquery (newest .values ('member__member' )[:1 ])) # add last com mail
57+ .exclude (last_comment_member = True ) # exclude when last com contain out url in email (member)
58+ .order_by ("-last_com" ) # order by last com
5359 )
5460
5561 def get_context_data (self , ** kwargs ):
Original file line number Diff line number Diff line change 3333# Application definition
3434
3535INSTALLED_APPS = [
36- "sslserver" ,
37- "django_extensions" ,
3836 "django.contrib.auth" ,
3937 "django.contrib.admin" ,
4038 "django.contrib.sessions" ,
You can’t perform that action at this time.
0 commit comments