Skip to content

Commit

Permalink
Test sparql logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mboudet committed May 10, 2023
1 parent c7273b0 commit ddcc5a8
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions askomics/libaskomics/SparqlQuery.py
Expand Up @@ -1385,7 +1385,15 @@ def build_query_from_json(self, preview=False, for_editor=False):
attributes[attribute["linkedWith"]]["entity_id"],
attributes[attribute["linkedWith"]]["label"]
))
var_to_replace.append((obj, var_2))
if any([filter.filterSign == "=" and not filter.filterValue for filter in attribute.get('linkedFilters', [])]):
var_to_replace.append((obj, var_2))
else:
for filter in attribute.get('linkedFilters', []):
modifier_string = ""
if filter.filterValue:
modifier_string = " {} {}".format(filter.filterModifier, filter.filterValue)
filter_string = "FILTER ( {} {} {} ) .".format(obj, var_2, modifier_string)
self.store_filter(filter_string, block_id, sblock_id, pblock_ids)

if attribute["type"] == "date":
if attribute["visible"] or Utils.check_key_in_list_of_dict(attribute["filters"], "filterValue") or attribute["id"] in linked_attributes:
Expand Down Expand Up @@ -1416,7 +1424,15 @@ def build_query_from_json(self, preview=False, for_editor=False):
attributes[attribute["linkedWith"]]["entity_id"],
attributes[attribute["linkedWith"]]["label"]
))
var_to_replace.append((obj, var_2))
if any([filter.filterSign == "=" and not filter.filterValue for filter in attribute.get('linkedFilters', [])]):
var_to_replace.append((obj, var_2))
else:
for filter in attribute.get('linkedFilters', []):
modifier_string = ""
if filter.filterValue:
modifier_string = " {} {}".format(filter.filterModifier, filter.filterValue)
filter_string = "FILTER ( {} {} {} ) .".format(obj, var_2, modifier_string)
self.store_filter(filter_string, block_id, sblock_id, pblock_ids)

# Category
if attribute["type"] == "category":
Expand Down

0 comments on commit ddcc5a8

Please sign in to comment.