@@ -33,17 +33,12 @@ def setUp(self) -> None:
3333 self .project3 = self .create_project (organization = self .org2 )
3434
3535 self .user2 = self .create_user (is_superuser = False )
36- self .user3 = self .create_user (is_superuser = False )
3736 self .create_member (user = self .user2 , organization = self .organization , role = "member" , teams = [])
3837 self .create_member (user = self .user2 , organization = self .org3 , role = "member" , teams = [])
3938 self .project4 = self .create_project (
4039 name = "users2sproj" ,
4140 teams = [self .create_team (organization = self .org , members = [self .user2 ])],
4241 )
43- self .project5 = self .create_project (
44- name = "users3sproj" ,
45- teams = [self .create_team (organization = self .org , members = [self .user3 ])],
46- )
4742
4843 self .store_outcomes (
4944 {
@@ -90,18 +85,6 @@ def setUp(self) -> None:
9085 "quantity" : 1 ,
9186 }
9287 )
93- self .store_outcomes (
94- {
95- "org_id" : self .org .id ,
96- "timestamp" : self ._now - timedelta (hours = 1 ),
97- "project_id" : self .project5 .id ,
98- "outcome" : Outcome .ACCEPTED ,
99- "reason" : "none" ,
100- "category" : DataCategory .ERROR ,
101- "quantity" : 1 ,
102- },
103- 2 ,
104- )
10588
10689 # Add profile_duration outcome data
10790 self .store_outcomes (
@@ -301,7 +284,7 @@ def test_timeseries_interval(self) -> None:
301284 isoformat_z (floor_to_utc_day (self ._now )),
302285 ],
303286 "groups" : [
304- {"by" : {}, "series" : {"sum(quantity)" : [0 , 8 ]}, "totals" : {"sum(quantity)" : 8 }}
287+ {"by" : {}, "series" : {"sum(quantity)" : [0 , 6 ]}, "totals" : {"sum(quantity)" : 6 }}
305288 ],
306289 "start" : isoformat_z (floor_to_utc_day (self ._now ) - timedelta (days = 1 )),
307290 "end" : isoformat_z (floor_to_utc_day (self ._now ) + timedelta (days = 1 )),
@@ -329,8 +312,8 @@ def test_timeseries_interval(self) -> None:
329312 "groups" : [
330313 {
331314 "by" : {},
332- "series" : {"sum(quantity)" : [0 , 0 , 0 , 8 , 0 ]},
333- "totals" : {"sum(quantity)" : 8 },
315+ "series" : {"sum(quantity)" : [0 , 0 , 0 , 6 , 0 ]},
316+ "totals" : {"sum(quantity)" : 6 },
334317 }
335318 ],
336319 "start" : isoformat_z (
@@ -361,7 +344,7 @@ def test_user_org_total_all_accessible(self) -> None:
361344 isoformat_z (floor_to_utc_day (self ._now )),
362345 ],
363346 "groups" : [
364- {"by" : {}, "series" : {"sum(quantity)" : [0 , 9 ]}, "totals" : {"sum(quantity)" : 9 }}
347+ {"by" : {}, "series" : {"sum(quantity)" : [0 , 7 ]}, "totals" : {"sum(quantity)" : 7 }}
365348 ],
366349 }
367350
@@ -467,10 +450,6 @@ def test_open_membership_semantics(self) -> None:
467450 "by" : {"project" : self .project2 .id },
468451 "totals" : {"sum(quantity)" : 1 },
469452 },
470- {
471- "by" : {"project" : self .project5 .id },
472- "totals" : {"sum(quantity)" : 2 },
473- },
474453 ],
475454 }
476455
@@ -994,118 +973,6 @@ def test_profile_duration_groupby(self) -> None:
994973 ],
995974 }
996975
997- @freeze_time (_now )
998- def test_project_filtering_with_all_projects (self ) -> None :
999- """Test that project=-1 aggregates data across all projects in the org"""
1000- response = self .do_request (
1001- {
1002- "project" : [- 1 ],
1003- "statsPeriod" : "1d" ,
1004- "interval" : "1d" ,
1005- "field" : ["sum(quantity)" ],
1006- "category" : ["error" , "transaction" ],
1007- },
1008- status_code = 200 ,
1009- )
1010-
1011- assert response .data ["groups" ] == [
1012- {
1013- "by" : {},
1014- "totals" : {"sum(quantity)" : 9 },
1015- "series" : {"sum(quantity)" : [0 , 9 ]},
1016- }
1017- ]
1018-
1019- @freeze_time (_now )
1020- def test_project_filtering_without_project_param (self ) -> None :
1021- """Test that when no project parameter is provided, it filters by user's projects (my projects)"""
1022- response = self .do_request (
1023- {
1024- "statsPeriod" : "1d" ,
1025- "interval" : "1d" ,
1026- "field" : ["sum(quantity)" ],
1027- "category" : ["error" , "transaction" ],
1028- },
1029- status_code = 200 ,
1030- )
1031-
1032- assert response .data ["groups" ] == [
1033- {
1034- "by" : {},
1035- "totals" : {"sum(quantity)" : 7 },
1036- "series" : {"sum(quantity)" : [0 , 7 ]},
1037- }
1038- ]
1039-
1040- @freeze_time (_now )
1041- def test_project_filtering_with_specific_project (self ) -> None :
1042- """Test that when a specific project id is provided, it filters by that project only"""
1043- response = self .do_request (
1044- {
1045- "project" : [self .project .id ],
1046- "statsPeriod" : "1d" ,
1047- "interval" : "1d" ,
1048- "field" : ["sum(quantity)" ],
1049- "category" : ["error" , "transaction" ],
1050- },
1051- status_code = 200 ,
1052- )
1053-
1054- assert response .data ["groups" ] == [
1055- {
1056- "by" : {},
1057- "totals" : {"sum(quantity)" : 6 },
1058- "series" : {"sum(quantity)" : [0 , 6 ]},
1059- }
1060- ]
1061-
1062- @freeze_time (_now )
1063- def test_project_filtering_with_multiple_specific_projects (self ) -> None :
1064- """Test filtering with multiple specific project IDs"""
1065- response = self .do_request (
1066- {
1067- "project" : [self .project .id , self .project2 .id ],
1068- "statsPeriod" : "1d" ,
1069- "interval" : "1d" ,
1070- "field" : ["sum(quantity)" ],
1071- "category" : ["error" , "transaction" ],
1072- },
1073- status_code = 200 ,
1074- )
1075-
1076- assert response .data ["groups" ] == [
1077- {
1078- "by" : {},
1079- "totals" : {"sum(quantity)" : 7 },
1080- "series" : {"sum(quantity)" : [0 , 7 ]},
1081- }
1082- ]
1083-
1084- @freeze_time (_now )
1085- def test_with_groupby_project (self ) -> None :
1086- """Test that groupBy=project shows individual project stats"""
1087- response = self .do_request (
1088- {
1089- "statsPeriod" : "1d" ,
1090- "interval" : "1d" ,
1091- "field" : ["sum(quantity)" ],
1092- "category" : ["error" , "transaction" ],
1093- "groupBy" : ["project" ],
1094- },
1095- status_code = 200 ,
1096- )
1097-
1098- assert response .data ["groups" ] == [
1099- {
1100- "by" : {"project" : self .project .id },
1101- "totals" : {"sum(quantity)" : 6 },
1102- },
1103- {
1104- "by" : {"project" : self .project2 .id },
1105- "totals" : {"sum(quantity)" : 1 },
1106- },
1107- ]
1108-
1109976
1110977def result_sorted (result ):
1111978 """sort the groups of the results array by the `by` object, ensuring a stable order"""
0 commit comments