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

Migrate some django_apps to shared #1089

Merged
merged 1 commit into from
Jan 14, 2025
Merged
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
6 changes: 5 additions & 1 deletion codecov/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,13 @@
# Allows to do migrations from another module
MIGRATION_MODULES = {
"codecov_auth": "shared.django_apps.codecov_auth.migrations",
"compare": "shared.django_apps.compare.migrations",
"core": "shared.django_apps.core.migrations",
"reports": "shared.django_apps.reports.migrations",
"labelanalysis": "shared.django_apps.labelanalysis.migrations",
"legacy_migrations": "shared.django_apps.legacy_migrations.migrations",
"profiling": "shared.django_apps.profiling.migrations",
"reports": "shared.django_apps.reports.migrations",
"staticanalysis": "shared.django_apps.staticanalysis.migrations",
}

# to aid in debugging, print out this info on startup. If no license, prints nothing
Expand Down
62 changes: 0 additions & 62 deletions compare/migrations/0001_initial.py

This file was deleted.

15 changes: 0 additions & 15 deletions compare/migrations/0002_commitcomparison_patch_totals.py

This file was deleted.

21 changes: 0 additions & 21 deletions compare/migrations/0003_commitcomparison_error.py

This file was deleted.

46 changes: 0 additions & 46 deletions compare/migrations/0004_flagcomparison.py

This file was deleted.

32 changes: 0 additions & 32 deletions compare/migrations/0005_auto_20220713_2210.py

This file was deleted.

43 changes: 0 additions & 43 deletions compare/migrations/0006_componentcomparison_and_more.py

This file was deleted.

Empty file removed compare/migrations/__init__.py
Empty file.
79 changes: 1 addition & 78 deletions compare/models.py
Original file line number Diff line number Diff line change
@@ -1,78 +1 @@
from django.db import models
from django_prometheus.models import ExportModelOperationsMixin

from codecov.models import BaseCodecovModel
from core.models import Commit
from reports.models import RepositoryFlag


class CommitComparison(
ExportModelOperationsMixin("compare.commit_comparison"), BaseCodecovModel
):
class CommitComparisonStates(models.TextChoices):
PENDING = "pending"
ERROR = "error"
PROCESSED = "processed"

class CommitComparisonErrors(models.TextChoices):
MISSING_BASE_REPORT = "missing_base_report"
MISSING_HEAD_REPORT = "missing_head_report"

base_commit = models.ForeignKey(
Commit, on_delete=models.CASCADE, related_name="base_commit_comparisons"
)
compare_commit = models.ForeignKey(
Commit, on_delete=models.CASCADE, related_name="compare_commit_comparisons"
)
state = models.TextField(
choices=CommitComparisonStates.choices, default=CommitComparisonStates.PENDING
)
error = models.TextField(choices=CommitComparisonErrors.choices, null=True)
report_storage_path = models.CharField(max_length=150, null=True, blank=True)
patch_totals = models.JSONField(null=True)

class Meta:
constraints = [
models.UniqueConstraint(
name="unique_comparison_between_commit",
fields=["base_commit", "compare_commit"],
)
]

@property
def is_processed(self):
return self.state == CommitComparison.CommitComparisonStates.PROCESSED


class FlagComparison(
ExportModelOperationsMixin("compare.flag_comparison"), BaseCodecovModel
):
commit_comparison = models.ForeignKey(
CommitComparison, on_delete=models.CASCADE, related_name="flag_comparisons"
)
repositoryflag = models.ForeignKey(
RepositoryFlag, on_delete=models.CASCADE, related_name="flag_comparisons"
)
head_totals = models.JSONField(null=True)
base_totals = models.JSONField(null=True)
patch_totals = models.JSONField(null=True)


class ComponentComparison(
ExportModelOperationsMixin("compare.component_comparison"), BaseCodecovModel
):
commit_comparison = models.ForeignKey(
CommitComparison, on_delete=models.CASCADE, related_name="component_comparisons"
)
component_id = models.TextField(null=False, blank=False)
head_totals = models.JSONField(null=True)
base_totals = models.JSONField(null=True)
patch_totals = models.JSONField(null=True)

class Meta:
indexes = [
models.Index(
fields=["commit_comparison_id", "component_id"],
name="component_comparison_component",
),
]
from shared.django_apps.compare.models import *
Loading
Loading