Browse Source

feat(replays): Add support for sorting by project-id (#38301)

Colton Allen 2 years ago
parent
commit
7fb94b825f

+ 3 - 0
src/sentry/replays/query.py

@@ -260,6 +260,7 @@ def _grouped_unique_scalar_value(
 replay_url_parser_config = SearchConfig(
     numeric_keys={"duration", "countErrors", "countSegments"},
     allowed_keys={
+        "projectId",
         "platform",
         "release",
         "dist",
@@ -313,6 +314,8 @@ class ReplayQueryConfig(QueryConfig):
     # Sort keys
     started_at = String(name="startedAt", is_filterable=False)
     finished_at = String(name="finishedAt", is_filterable=False)
+    # Dedicated url parameter should be used.
+    project_id = String(field_alias="projectId", query_alias="projectId", is_filterable=False)
 
 
 # Pagination.

+ 5 - 3
tests/sentry/replays/test_organization_replay_index.py

@@ -320,7 +320,7 @@ class OrganizationReplayIndexTest(APITestCase, ReplaysSnubaTestCase):
                 seq1_timestamp,
                 project.id,
                 replay1_id,
-                platform="javascript client",
+                platform="javascript",
                 dist="abc123",
                 user_id="123",
                 user_email="username@example.com",
@@ -394,6 +394,7 @@ class OrganizationReplayIndexTest(APITestCase, ReplaysSnubaTestCase):
     def test_get_replays_user_sorts(self):
         """Test replays conform to the interchange format."""
         project = self.create_project(teams=[self.team])
+        project2 = self.create_project(teams=[self.team])
 
         replay1_id = uuid.uuid4().hex
         seq1_timestamp = datetime.datetime.now() - datetime.timedelta(seconds=15)
@@ -401,7 +402,7 @@ class OrganizationReplayIndexTest(APITestCase, ReplaysSnubaTestCase):
         self.store_replays(
             mock_replay(
                 seq1_timestamp,
-                project.id,
+                project2.id,
                 replay1_id,
                 platform="b",
                 dist="b",
@@ -424,7 +425,7 @@ class OrganizationReplayIndexTest(APITestCase, ReplaysSnubaTestCase):
         self.store_replays(
             mock_replay(
                 seq2_timestamp,
-                project.id,
+                project2.id,
                 replay1_id,
                 platform="b",
                 dist="b",
@@ -498,6 +499,7 @@ class OrganizationReplayIndexTest(APITestCase, ReplaysSnubaTestCase):
         with self.feature(REPLAYS_FEATURES):
             # Run all the queries individually to determine compliance.
             queries = [
+                "projectId",
                 "platform",
                 "dist",
                 "duration",