Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(stats.py): Add a fallback for old assignments and stats #504

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion argus/backend/service/argus_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,8 @@ def get_tests_assignees(self, group_id: UUID | str, version: str = None, plan_id

release = ArgusRelease.get(id=group.release_id)
if not release.perpetual:
return PlanningService().get_assignments_for_tests(group_id, version, plan_id)
if assignments := PlanningService().get_assignments_for_tests(group_id, version, plan_id):
return assignments

tests = ArgusTest.filter(group_id=group_id).all()

Expand Down
18 changes: 14 additions & 4 deletions argus/backend/service/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from argus.backend.plugins.loader import all_plugin_models
from argus.backend.util.common import chunk, get_build_number
from argus.common.enums import TestStatus, TestInvestigationStatus
from argus.backend.models.web import ArgusGithubIssue, ArgusRelease, ArgusGroup, ArgusTest,\
from argus.backend.models.web import ArgusGithubIssue, ArgusRelease, ArgusGroup, ArgusScheduleTest, ArgusTest,\
ArgusTestRunComment, ArgusUserView
from argus.backend.db import ScyllaCluster

Expand Down Expand Up @@ -248,6 +248,7 @@ def __init__(self, release: ArgusRelease) -> None:
self.issues: list[ArgusGithubIssue] = []
self.comments: list[ArgusTestRunComment] = []
self.plans: list[ArgusReleasePlan] = []
self.schedules = {}
self.forced_collection = False
self.rows = []
self.all_tests = []
Expand Down Expand Up @@ -285,6 +286,11 @@ def collect(self, rows: list[TestRunStatRow], limited=False, force=False, dict:
if not self.release.perpetual and not limited:
plans: list[ArgusReleasePlan] = list(ArgusReleasePlan.filter(release_id=self.release.id).all())
self.plans = plans if not filter else [plan for plan in plans if version_filter == plan.target_version]
self.test_schedules = reduce(
lambda acc, row: acc[row["test_id"]].append(row) or acc,
ArgusScheduleTest.filter(release_id=self.release.id).all(),
defaultdict(list)
)

self.rows = rows
self.dict = dict
Expand Down Expand Up @@ -361,7 +367,8 @@ def collect(self, limited=False):
stats = TestStats(
test=test,
parent_group=self,
scheduled=is_scheduled
scheduled=is_scheduled,
schedules=self.parent_release.test_schedules.get(test.id, []),
)
stats.collect(limited=limited)
self.tests.append(stats)
Expand All @@ -378,7 +385,8 @@ def __init__(
self,
test: ArgusTest,
parent_group: GroupStats,
scheduled: bool = False
scheduled: bool = False,
schedules: list[ArgusScheduleTest] | None = None,
) -> None:
self.test = test
self.parent_group = parent_group
Expand All @@ -389,6 +397,8 @@ def __init__(
self.has_bug_report = False
self.has_comments = False
self.is_scheduled = scheduled
self.schedules = schedules if schedules else tuple()
self.is_scheduled_legacy = len(self.schedules) > 0 # TODO: Remove once old scheduling system is removed
self.tracked_run_number = None

def to_dict(self) -> dict:
Expand Down Expand Up @@ -417,7 +427,7 @@ def collect(self, limited=False):
try:
last_run = last_runs[0]
except IndexError:
self.status = TestStatus.NOT_RUN if self.is_scheduled else TestStatus.NOT_PLANNED
self.status = TestStatus.NOT_RUN if self.is_scheduled or self.is_scheduled_legacy else TestStatus.NOT_PLANNED
self.parent_group.increment_status(status=self.status)
return
status_map = generate_field_status_map(last_runs)
Expand Down
Loading