Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 3653469

Browse files
committed
add more undocumented relations
1 parent 1d61cc3 commit 3653469

File tree

3 files changed

+53
-6
lines changed

3 files changed

+53
-6
lines changed

services/cleanup/relations.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
from django.db.models import Model, Q
66
from django.db.models.query import QuerySet
7+
from shared.django_apps.bundle_analysis.models import CacheConfig
78
from shared.django_apps.codecov_auth.models import Owner, OwnerProfile
89
from shared.django_apps.core.models import Commit, Pull, Repository
910
from shared.django_apps.reports.models import DailyTestRollup, TestInstance
11+
from shared.django_apps.user_measurements.models import UserMeasurement
1012

1113
# Relations referencing 0 through field 1 of model 2:
1214
IGNORE_RELATIONS: set[tuple[type[Model], str, type[Model]]] = {
@@ -22,6 +24,12 @@
2224
UNDOCUMENTED_RELATIONS: set[tuple[type[Model], str, type[Model]]] = {
2325
(Repository, "repoid", TestInstance),
2426
(Repository, "repoid", DailyTestRollup),
27+
(Commit, "commit_id", UserMeasurement),
28+
(Owner, "owner_id", UserMeasurement),
29+
(Repository, "repo_id", UserMeasurement),
30+
(Repository, "repo_id", CacheConfig),
31+
# TODO: `UserMeasurement` also has `upload_id`, should we register that as well?
32+
# TODO: should we also include `SimpleMetric` here?
2533
}
2634

2735

services/cleanup/tests/snapshots/relations__builds_delete_queries__owner.txt

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
-- UserMeasurement
2+
DELETE
3+
FROM "user_measurements"
4+
WHERE "user_measurements"."owner_id" IN
5+
(SELECT U0."ownerid"
6+
FROM "owners" U0
7+
WHERE U0."ownerid" = %s)
8+
9+
110
-- YamlHistory
211
DELETE
312
FROM "yaml_history"
@@ -68,10 +77,10 @@ WHERE "codecov_auth_usertoken"."ownerid" IN
6877
WHERE U0."ownerid" = %s)
6978

7079

71-
-- TestInstance
80+
-- CacheConfig
7281
DELETE
73-
FROM "reports_testinstance"
74-
WHERE "reports_testinstance"."repoid" IN
82+
FROM "bundle_analysis_cacheconfig"
83+
WHERE "bundle_analysis_cacheconfig"."repo_id" IN
7584
(SELECT V0."repoid"
7685
FROM "repos" V0
7786
WHERE V0."ownerid" IN
@@ -92,6 +101,18 @@ WHERE "reports_dailytestrollups"."repoid" IN
92101
WHERE U0."ownerid" = %s))
93102

94103

104+
-- TestInstance
105+
DELETE
106+
FROM "reports_testinstance"
107+
WHERE "reports_testinstance"."repoid" IN
108+
(SELECT V0."repoid"
109+
FROM "repos" V0
110+
WHERE V0."ownerid" IN
111+
(SELECT U0."ownerid"
112+
FROM "owners" U0
113+
WHERE U0."ownerid" = %s))
114+
115+
95116
-- RepositoryToken
96117
DELETE
97118
FROM "codecov_auth_repositorytoken"

services/cleanup/tests/snapshots/relations__builds_delete_queries__repository.txt

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
-- TestInstance
1+
-- CacheConfig
22
DELETE
3-
FROM "reports_testinstance"
4-
WHERE "reports_testinstance"."repoid" IN
3+
FROM "bundle_analysis_cacheconfig"
4+
WHERE "bundle_analysis_cacheconfig"."repo_id" IN
55
(SELECT U0."repoid"
66
FROM "repos" U0
77
WHERE U0."repoid" = %s)
@@ -16,6 +16,24 @@ WHERE "reports_dailytestrollups"."repoid" IN
1616
WHERE U0."repoid" = %s)
1717

1818

19+
-- TestInstance
20+
DELETE
21+
FROM "reports_testinstance"
22+
WHERE "reports_testinstance"."repoid" IN
23+
(SELECT U0."repoid"
24+
FROM "repos" U0
25+
WHERE U0."repoid" = %s)
26+
27+
28+
-- UserMeasurement
29+
DELETE
30+
FROM "user_measurements"
31+
WHERE "user_measurements"."repo_id" IN
32+
(SELECT U0."repoid"
33+
FROM "repos" U0
34+
WHERE U0."repoid" = %s)
35+
36+
1937
-- RepositoryToken
2038
DELETE
2139
FROM "codecov_auth_repositorytoken"

0 commit comments

Comments
 (0)