File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 8
8
uniqExact ,
9
9
uniqHLL12 ,
10
10
uniqTheta ,
11
+ anyLast
11
12
)
12
13
13
14
from .models import WatchSeries
@@ -28,6 +29,14 @@ class AggregatesTestCase(TestCase):
28
29
{"show" : "Game of Thrones" , "episode" : "S1E2" , "uid_count" : 1 },
29
30
]
30
31
32
+ expected_result_any_last = [
33
+ {'uid' : 'alice' , 'user_last_watched_show' : 'Game of Thrones' },
34
+ {'uid' : 'bob' , 'user_last_watched_show' : 'Bridgerton' },
35
+ {'uid' : 'carol' , 'user_last_watched_show' : 'Bridgerton' },
36
+ {'uid' : 'dan' , 'user_last_watched_show' : 'Bridgerton' },
37
+ {'uid' : 'erin' , 'user_last_watched_show' : 'Game of Thrones' },
38
+ ]
39
+
31
40
@classmethod
32
41
def setUpTestData (cls ):
33
42
data_list = [
@@ -227,3 +236,15 @@ def test_uniqhll12(self):
227
236
228
237
def test_uniqtheta (self ):
229
238
self ._test (uniqTheta )
239
+
240
+ def test_anylast (self ):
241
+ result = (
242
+ WatchSeries .objects .values ("uid" )
243
+ .annotate (user_last_watched_show = anyLast ("show" ))
244
+ .order_by ("uid" )
245
+ )
246
+
247
+ self .assertQuerysetEqual (
248
+ result , self .expected_result_any_last , transform = dict
249
+ )
250
+
You can’t perform that action at this time.
0 commit comments