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 88 uniqExact ,
99 uniqHLL12 ,
1010 uniqTheta ,
11+ anyLast
1112)
1213
1314from .models import WatchSeries
@@ -28,6 +29,14 @@ class AggregatesTestCase(TestCase):
2829 {"show" : "Game of Thrones" , "episode" : "S1E2" , "uid_count" : 1 },
2930 ]
3031
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+
3140 @classmethod
3241 def setUpTestData (cls ):
3342 data_list = [
@@ -227,3 +236,15 @@ def test_uniqhll12(self):
227236
228237 def test_uniqtheta (self ):
229238 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