Skip to content

Commit 630351b

Browse files
committed
Remove isQA from model, duplicative of qaRunId
1 parent 2099876 commit 630351b

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

backend/btrixcloud/crawl_logs.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,31 @@ async def init_index(self):
3535
[
3636
("crawl_id", pymongo.HASHED),
3737
("oid", pymongo.ASCENDING),
38-
("isQA", pymongo.ASCENDING),
38+
("qaRunId", pymongo.ASCENDING),
3939
("timestamp", pymongo.ASCENDING),
4040
]
4141
)
4242
await self.logs.create_index(
4343
[
4444
("crawl_id", pymongo.HASHED),
4545
("oid", pymongo.ASCENDING),
46-
("isQA", pymongo.ASCENDING),
46+
("qaRunId", pymongo.ASCENDING),
4747
("logLevel", pymongo.ASCENDING),
4848
]
4949
)
5050
await self.logs.create_index(
5151
[
5252
("crawl_id", pymongo.HASHED),
5353
("oid", pymongo.ASCENDING),
54-
("isQA", pymongo.ASCENDING),
54+
("qaRunId", pymongo.ASCENDING),
5555
("context", pymongo.ASCENDING),
5656
]
5757
)
5858
await self.logs.create_index(
5959
[
6060
("crawl_id", pymongo.HASHED),
6161
("oid", pymongo.ASCENDING),
62-
("isQA", pymongo.ASCENDING),
62+
("qaRunId", pymongo.ASCENDING),
6363
("message", pymongo.ASCENDING),
6464
]
6565
)
@@ -68,7 +68,6 @@ async def add_log_line(
6868
self,
6969
crawl_id: str,
7070
oid: UUID,
71-
is_qa: bool,
7271
log_line: str,
7372
qa_run_id: Optional[str] = None,
7473
) -> bool:
@@ -90,7 +89,6 @@ async def add_log_line(
9089
id=uuid4(),
9190
crawl_id=crawl_id,
9291
oid=oid,
93-
isQA=is_qa,
9492
qaRunId=qa_run_id,
9593
timestamp=log_dict["timestamp"],
9694
logLevel=log_dict["logLevel"],
@@ -118,6 +116,7 @@ async def get_crawl_logs(
118116
sort_direction: int = -1,
119117
contexts: Optional[List[str]] = None,
120118
log_levels: Optional[List[str]] = None,
119+
qa_run_id: Optional[str] = None,
121120
) -> Tuple[list[CrawlLogLine], int]:
122121
"""list all logs for particular crawl"""
123122
# pylint: disable=too-many-locals, duplicate-code
@@ -129,8 +128,7 @@ async def get_crawl_logs(
129128
match_query: Dict[str, Any] = {
130129
"oid": org.id,
131130
"crawl_id": crawl_id,
132-
# For now, only return non-QA crawl logs
133-
"isQA": False,
131+
"qaRunId": qa_run_id,
134132
}
135133

136134
if contexts:

backend/btrixcloud/crawls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,7 @@ async def get_crawl_errors(
17071707
sort_by=sortBy,
17081708
sort_direction=sortDirection,
17091709
log_levels=["error", "fatal"],
1710+
qa_run_id=None,
17101711
)
17111712
return paginated_format(log_lines, total, page, pageSize)
17121713

@@ -1731,6 +1732,7 @@ async def get_crawl_behavior_logs(
17311732
sort_by=sortBy,
17321733
sort_direction=sortDirection,
17331734
contexts=["behavior", "behaviorScript", "behaviorScriptCustom"],
1735+
qa_run_id=None,
17341736
)
17351737
return paginated_format(log_lines, total, page, pageSize)
17361738

backend/btrixcloud/migrations/migration_0050_crawl_logs.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ async def migrate_up(self):
4343
await self.crawl_log_ops.add_log_line(
4444
crawl_id=crawl_id,
4545
oid=crawl_dict["oid"],
46-
is_qa=False,
4746
log_line=error_log,
4847
qa_run_id=None,
4948
)
@@ -53,7 +52,6 @@ async def migrate_up(self):
5352
await self.crawl_log_ops.add_log_line(
5453
crawl_id=crawl_id,
5554
oid=crawl_dict["oid"],
56-
is_qa=False,
5755
log_line=behavior_log,
5856
qa_run_id=None,
5957
)
@@ -95,7 +93,6 @@ async def migrate_up(self):
9593
await self.crawl_log_ops.add_log_line(
9694
crawl_id=crawl_id,
9795
oid=crawl_with_qa["oid"],
98-
is_qa=True,
9996
log_line=qa_error_log,
10097
qa_run_id=qa_run_id,
10198
)
@@ -105,7 +102,6 @@ async def migrate_up(self):
105102
await self.crawl_log_ops.add_log_line(
106103
crawl_id=crawl_id,
107104
oid=crawl_with_qa["oid"],
108-
is_qa=True,
109105
log_line=qa_behavior_log,
110106
qa_run_id=qa_run_id,
111107
)

backend/btrixcloud/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,6 @@ class CrawlLogLine(BaseMongoModel):
11541154
crawl_id: str
11551155
oid: UUID
11561156

1157-
isQA: bool = False
11581157
qaRunId: Optional[str] = None
11591158

11601159
timestamp: datetime
@@ -1163,6 +1162,11 @@ class CrawlLogLine(BaseMongoModel):
11631162
message: str
11641163
details: Optional[Dict[str, Any]] = None
11651164

1165+
@property
1166+
def is_qa(self) -> bool:
1167+
"""return true if log line is from qa run"""
1168+
return bool(self.qaRunId)
1169+
11661170

11671171
# ============================================================================
11681172

backend/btrixcloud/operator/crawls.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,6 @@ async def sync_crawl_state(
10211021
await self.crawl_log_ops.add_log_line(
10221022
crawl.db_crawl_id,
10231023
crawl.oid,
1024-
is_qa=crawl.is_qa,
10251024
log_line=crawl_error,
10261025
qa_run_id=qa_run_id,
10271026
)
@@ -1032,7 +1031,6 @@ async def sync_crawl_state(
10321031
await self.crawl_log_ops.add_log_line(
10331032
crawl.db_crawl_id,
10341033
crawl.oid,
1035-
is_qa=crawl.is_qa,
10361034
log_line=behavior_log,
10371035
qa_run_id=qa_run_id,
10381036
)

0 commit comments

Comments
 (0)