Skip to content

Commit

Permalink
refactor: migrate seqvars to TanStack Query (#2090) (#2094)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Nov 7, 2024
1 parent cb16a6e commit 24475ba
Show file tree
Hide file tree
Showing 32 changed files with 5,204 additions and 1,681 deletions.
18 changes: 10 additions & 8 deletions backend/seqvars/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ def clone_with_presetsset(
# First, handle the "normal" presets categories. A side-effect of the
# code below is that the UUIDs of the presets are changed and we rely
# on this when createing the predefined queries.
uuid_old_to_new = {}
for key in (
"seqvarsquerypresetsfrequency_set",
"seqvarsquerypresetsvariantprio_set",
Expand All @@ -628,6 +629,7 @@ def clone_with_presetsset(
obj.id = None
obj._state.adding = True
new_uuid = uuid_object.uuid4()
uuid_old_to_new[obj.sodar_uuid] = new_uuid
obj.sodar_uuid = new_uuid
obj.presetssetversion = result
obj.save()
Expand All @@ -640,28 +642,28 @@ def clone_with_presetsset(
obj.sodar_uuid = uuid_object.uuid4()
obj.presetssetversion = result
obj.quality = SeqvarsQueryPresetsQuality.objects.get(
sodar_uuid=obj.quality.sodar_uuid,
sodar_uuid=uuid_old_to_new[obj.quality.sodar_uuid],
)
obj.frequency = SeqvarsQueryPresetsFrequency.objects.get(
sodar_uuid=obj.frequency.sodar_uuid,
sodar_uuid=uuid_old_to_new[obj.frequency.sodar_uuid],
)
obj.consequence = SeqvarsQueryPresetsConsequence.objects.get(
sodar_uuid=obj.consequence.sodar_uuid,
sodar_uuid=uuid_old_to_new[obj.consequence.sodar_uuid],
)
obj.locus = SeqvarsQueryPresetsLocus.objects.get(
sodar_uuid=obj.locus.sodar_uuid,
sodar_uuid=uuid_old_to_new[obj.locus.sodar_uuid],
)
obj.phenotypeprio = SeqvarsQueryPresetsPhenotypePrio.objects.get(
sodar_uuid=obj.phenotypeprio.sodar_uuid,
sodar_uuid=uuid_old_to_new[obj.phenotypeprio.sodar_uuid],
)
obj.variantprio = SeqvarsQueryPresetsVariantPrio.objects.get(
sodar_uuid=obj.variantprio.sodar_uuid,
sodar_uuid=uuid_old_to_new[obj.variantprio.sodar_uuid],
)
obj.clinvar = SeqvarsQueryPresetsClinvar.objects.get(
sodar_uuid=obj.clinvar.sodar_uuid,
sodar_uuid=uuid_old_to_new[obj.clinvar.sodar_uuid],
)
obj.columns = SeqvarsQueryPresetsColumns.objects.get(
sodar_uuid=obj.columns.sodar_uuid,
sodar_uuid=uuid_old_to_new[obj.columns.sodar_uuid],
)
obj.save()

Expand Down
1 change: 1 addition & 0 deletions backend/seqvars/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def test_clone_factory_default(self):
# Note: only smoke test implemented so far.
project = ProjectFactory()
querypresetset = create_seqvarspresetsset_short_read_genome()
querypresetset.save()
querypresetset.clone_with_latest_version(project=project)


Expand Down
1 change: 1 addition & 0 deletions backend/seqvars/tests/test_permissions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2134,6 +2134,7 @@ def cleanup():
def test_create_from(self):
# TODO: change after https://github.com/varfish-org/varfish-server/issues/1920
presetsset_factory = create_seqvarspresetsset_short_read_exome_legacy()
presetsset_factory.save()
presetsset = presetsset_factory.clone_with_latest_version(project=self.project)
version = presetsset.versions.all()[0]
predefinedquery = version.seqvarspredefinedquery_set.all()[0]
Expand Down
1 change: 1 addition & 0 deletions backend/seqvars/tests/test_views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2033,6 +2033,7 @@ def test_create_from(self):
with self.login(self.superuser):
# TODO: change after https://github.com/varfish-org/varfish-server/issues/1920
presetsset_factory = create_seqvarspresetsset_short_read_exome_legacy()
presetsset_factory.save()
presetsset = presetsset_factory.clone_with_latest_version(project=self.project)
version = presetsset.versions.all()[0]
predefinedquery = version.seqvarspredefinedquery_set.all()[0]
Expand Down
22 changes: 22 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"jquery": "^3.7.1",
"lodash.debounce": "^4.0.8",
"luxon": "^3.5.0",
"object-deep-merge": "^1.0.4",
"pinia": "^2.2.2",
"plotly.js-dist": "^2.34.0",
"remeda": "^2.6.0",
Expand Down
Loading

0 comments on commit 24475ba

Please sign in to comment.