Conversation
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
| # get all values of the project | ||
| values = project.values.filter(snapshot=None).select_related('attribute', 'option') | ||
| if conditions: | ||
| values = project.values.filter(snapshot=None).for_condition_resolution() |
There was a problem hiding this comment.
maybe better just without the ..select_related('attribute', 'option') and without the .for_condition_resolution()
|
|
||
| element_conditions = [conditions[condition_id] for condition_id in elements[element_type][element_id]] | ||
| params['result'] = check_conditions(element_conditions, values, set_prefix, set_index) | ||
| element_condition_ids = elements[element_type][element_id] |
There was a problem hiding this comment.
we also have already:
'attribute_map': (
Attribute.objects.get_queryset_ancestors(
Attribute.objects.filter(id__in=attribute_ids),
include_self=True
).in_bulk()from django.db.models.query.QuerySet.in_bulk
|
|
||
|
|
||
| def check_conditions(conditions, values, set_prefix=None, set_index=None): | ||
| def compute_values_by_attribute(values): |
There was a problem hiding this comment.
There was a problem hiding this comment.
no, the in_bulk does not work here because we want to get many Values per single Attribute:
attribute_id 10
→ Value(id=101, set_index=0)
→ Value(id=102, set_index=1)
→ Value(id=103, collection_index=1)
```|
|
||
| values = self.get_object().values.filter(snapshot_id=snapshot_id).select_related('attribute', 'option') | ||
| values = self.get_object().values.filter(snapshot_id=snapshot_id).for_condition_resolution() | ||
| values_by_attribute = compute_values_by_attribute(values) |
There was a problem hiding this comment.
no0o0o, attribute_values_map 😵
| values = project.values.filter(snapshot=None).select_related('attribute', 'option') | ||
| if conditions: | ||
| values = project.values.filter(snapshot=None).for_condition_resolution() | ||
| values_by_attribute = compute_values_by_attribute(values) |
| # get all values of the project | ||
| values = project.values.filter(snapshot=None).select_related('attribute', 'option') | ||
| if conditions: | ||
| values = project.values.filter(snapshot=None).for_condition_resolution() |
There was a problem hiding this comment.
Just without select_releated?
| element_conditions = [conditions[condition_id] for condition_id in elements[element_type][element_id]] | ||
| params['result'] = check_conditions(element_conditions, values, set_prefix, set_index) | ||
| element_condition_ids = elements[element_type][element_id] | ||
| cache_key = (tuple(sorted(element_condition_ids)), set_prefix, set_index) |
There was a problem hiding this comment.
we should try to re-use AnswerTree for checking/resolve the conditions in here. It is better when we define this duplicated logic in one-place and maybe we could then move the resolved AnserTree in a real cache for User request to make it 2x as fast!
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
|
unstacked and closed in favour of #1752 |
field_idgetter instead offield.idadd a.for_condition_resolution(self)method to theValueQuerySetvalues_by_attributedict of lists for theresolveaction