Skip to content

Commit

Permalink
fix: save_commit_measurements (#1057)
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-sentry authored Jan 31, 2025
1 parent 1b11603 commit f38b28c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion tasks/save_commit_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from services.timeseries import (
maybe_upsert_coverage_measurement,
maybe_upsert_flag_measurements,
repository_datasets_query,
upsert_components_measurements,
)
from services.yaml import get_repo_yaml
Expand Down Expand Up @@ -83,7 +84,7 @@ def run_impl(
db_session: Session,
commitid: str,
repoid: int,
dataset_names: Sequence[str],
dataset_names: Sequence[str] | None,
*args,
**kwargs,
):
Expand All @@ -106,6 +107,13 @@ def run_impl(
if commit is None:
return {"successful": False, "error": "no_commit_in_db"}

if dataset_names is None:
dataset_names = [
dataset.name for dataset in repository_datasets_query(commit.repository)
]
if len(dataset_names) == 0:
return

try:
# TODO: We should improve on the error handling/logs inside this fn
save_commit_measurements(commit=commit, dataset_names=dataset_names)
Expand Down
5 changes: 4 additions & 1 deletion tasks/upsert_component.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from shared.reports.readonly import ReadOnlyReport
from shared.utils.enums import TaskConfigGroup
from sqlalchemy.orm import Session

from app import celery_app
Expand All @@ -12,8 +13,10 @@

log = logging.getLogger(__name__)

task_name = f"app.tasks.{TaskConfigGroup.timeseries.value}.UpsertComponentTask"

class UpsertComponentTask(BaseCodecovTask):

class UpsertComponentTask(BaseCodecovTask, name=task_name):
def run_impl(
self,
db_session: Session,
Expand Down

0 comments on commit f38b28c

Please sign in to comment.