Skip to content

Commit

Permalink
Prefix tooltip now serverd by api/site_observation
Browse files Browse the repository at this point in the history
  • Loading branch information
kaliif committed Feb 14, 2024
1 parent 7fd97c9 commit f43eabf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions viewer/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def filter_qs(self):
).annotate(
target=F("experiment__experiment_upload__target"),
compound_code=F("cmpd__compound_code"),
prefix_tooltip=F("experiment__prefix_tooltip"),
)

return qs
Expand Down
1 change: 1 addition & 0 deletions viewer/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ class Meta:

class SiteObservationReadSerializer(serializers.ModelSerializer):
compound_code = serializers.StringRelatedField()
prefix_tooltip = serializers.StringRelatedField()

class Meta:
model = models.SiteObservation
Expand Down
10 changes: 5 additions & 5 deletions viewer/target_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1652,16 +1652,13 @@ def process_bundle(self):
canon_site_confs=canon_site_conf_objects,
)

values = ["xtalform_site__xtalform", "canon_site_conf__canon_site", "cmpd"]
values = ["canon_site_conf__canon_site", "cmpd"]
qs = (
SiteObservation.objects.values(*values)
.order_by(*values)
.annotate(obvs=ArrayAgg("id"))
.values_list("obvs", flat=True)
)
current_list = SiteObservation.objects.filter(
experiment__experiment_upload__target=self.target
).values_list('code', flat=True)
for elem in qs:
# objects in this group should be named with same scheme
so_group = SiteObservation.objects.filter(pk__in=elem)
Expand Down Expand Up @@ -1702,7 +1699,10 @@ def process_bundle(self):
# TODO: this should ideally be solved by db engine, before
# rushing to write the trigger, have think about the
# loader concurrency situations
if code in current_list:
if SiteObservation.objects.filter(
experiment__experiment_upload__target=self.target,
code=code,
).exists():
msg = (
f"short code {code} already exists for this target; "
+ "specify a code_prefix to resolve this conflict"
Expand Down

0 comments on commit f43eabf

Please sign in to comment.