Skip to content

Commit

Permalink
Merge pull request #10314 from archesproject/update_74x_with_62x
Browse files Browse the repository at this point in the history
Update 74x with latest bug fixes in 62x
  • Loading branch information
johnatawnclementawn authored Nov 30, 2023
2 parents 89db5a3 + fc5d62b commit 72b424b
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 48 deletions.
24 changes: 15 additions & 9 deletions arches/app/datatypes/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,21 +784,25 @@ def add_date_to_doc(document, edtf):

def append_search_filters(self, value, node, query, request):
def add_date_to_doc(query, edtf):
invalid_filter_exception = Exception(
_(
'Only dates that specify an exact year, month, \
and day can be used with the "=", ">", "<", ">=", and "<=" operators'
)
)

if value["op"] == "eq":
if edtf.lower != edtf.upper:
raise Exception(_('Only dates that specify an exact year, month, and day can be used with the "=" operator'))
query.should(Match(field="tiles.data.%s.dates.date" % (str(node.pk)), query=edtf.lower, type="phrase_prefix"))
raise invalid_filter_exception
else:
operators = {"gte": edtf.lower, "lte": edtf.lower}
query.must(Range(field="tiles.data.%s.dates.date" % (str(node.pk)), **operators))
else:
if value["op"] == "overlaps":
operators = {"gte": edtf.lower, "lte": edtf.upper}
else:
if edtf.lower != edtf.upper:
raise Exception(
_(
'Only dates that specify an exact year, month, \
and day can be used with the ">", "<", ">=", and "<=" operators'
)
)
raise invalid_filter_exception

operators = {value["op"]: edtf.lower or edtf.upper}

Expand All @@ -811,7 +815,9 @@ def add_date_to_doc(query, edtf):
if edtf.lower is None and edtf.upper is None:
raise Exception(_("Invalid date specified."))

if value["op"] == "null" or value["op"] == "not_null":
if not value.get('op'):
pass
elif value["op"] == "null" or value["op"] == "not_null":
self.append_null_search_filters(value, node, query, request)
elif value["val"] != "" and value["val"] is not None:
edtf = ExtendedDateFormat(value["val"])
Expand Down
1 change: 1 addition & 0 deletions arches/app/media/js/viewmodels/resource-instance-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ define([
queryString.set('term-filter', JSON.stringify(termFilter));
}
}
queryString.set('sort-results', 'asc')
return queryString.toString();
}
},
Expand Down
3 changes: 2 additions & 1 deletion arches/app/media/js/views/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ define([
this.viewModel.alert(false);
},
error: function(response, status, error) {
const alert = new AlertViewModel('ep-alert-red', arches.translations.requestFailed.title, response.responseJSON?.message);
if(this.updateRequest.statusText !== 'abort'){
this.viewModel.alert(new AlertViewModel('ep-alert-red', arches.translations.requestFailed.title, response.responseText));
this.viewModel.alert(alert);
}
},
complete: function(request, status) {
Expand Down
8 changes: 8 additions & 0 deletions arches/app/models/concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,13 @@ def get_child_edges(
FROM children c
JOIN values ON(values.conceptid = c.conceptidto)
WHERE LOWER(values.value) like %(query)s
AND values.valuetype in ('prefLabel')
AND LOWER(values.value) != %(match)s
UNION
SELECT c.conceptidfrom, c.conceptidto, '0' as row, c.depth, c.collector
FROM children c
JOIN values ON(values.conceptid = c.conceptidto)
WHERE LOWER(values.value) = %(match)s
AND values.valuetype in ('prefLabel')
UNION
SELECT c.conceptidfrom, c.conceptidto, c.row, c.depth, c.collector
Expand All @@ -663,6 +670,7 @@ def get_child_edges(
"limit": limit,
"offset": offset,
"query": "%" + query.lower() + "%",
"match": query.lower(),
"recursive_table": AsIs(recursive_table),
"languageid": languageid,
"short_languageid": languageid.split("-")[0] + "%",
Expand Down
37 changes: 0 additions & 37 deletions arches/app/views/concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,43 +393,6 @@ def paged_dropdown(request):
for d in data
]

# This try/except block trys to find an exact match to the concept the user is searching and if found
# it will insert it into the results as the first item so that users don't have to scroll to find it.
# See: https://github.com/archesproject/arches/issues/8355
try:
if page == 1:
found = False
for i, d in enumerate(data):
if i <= 7 and d["text"].lower() == query.lower():
found = True
break
if not found:
languageid = get_language().lower()
cursor = connection.cursor()
cursor.execute(
"""
SELECT value, valueid
FROM
(
SELECT *, CASE WHEN LOWER(languageid) = %(languageid)s THEN 10
WHEN LOWER(languageid) like %(short_languageid)s THEN 5
ELSE 0
END score
FROM values
) as vals
WHERE LOWER(value)=%(query)s AND score > 0
AND valuetype in ('prefLabel')
ORDER BY score desc limit 1
""",
{"languageid": languageid, "short_languageid": languageid.split("-")[0] + "%", "query": query.lower()},
)
rows = cursor.fetchall()

if len(rows) == 1:
data.insert(0, {"id": str(rows[0][1]), "text": rows[0][0], "depth": 1, "collector": False})
except:
pass

return JSONResponse({"results": data, "more": offset + limit < total_count})


Expand Down
2 changes: 1 addition & 1 deletion arches/app/views/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def search_results(request, returnDsl=False):
append_instance_permission_filter_dsl(request, search_results_object)
except Exception as err:
logger.exception(err)
return JSONErrorResponse(message=err)
return JSONErrorResponse(message=str(err))

dsl = search_results_object.pop("query", None)
if returnDsl:
Expand Down
3 changes: 3 additions & 0 deletions releases/6.2.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Arches 6.2.6 release notes
- Adds missing file renderers to project template #10171
- Fixes multiple EDTF nodes in single card used in advanced search returning too many records #10202
- Fixes error when handling multiple subcard levels in search export #10214
- Fixes edtf advanced search error message #10309
- Disallows selection of concepts outside of a collection in concept widget #10308
- Sorts resources in resource instance dropdown, #10305

### Dependency changes:
```
Expand Down
3 changes: 3 additions & 0 deletions releases/7.4.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Arches 7.4.3 release notes
- Hides separator line for invisible cards #10221
- Fixes resetting the maximum number of files for a file-list node #10229
- Fixes geometries not being updated for geojson nodes #10292
- Fixes edtf advanced search error message #10309
- Disallows selection of concepts outside of a collection in concept widget #10308
- Sorts resources in resource instance dropdown, #10305


### Dependency changes:
Expand Down

0 comments on commit 72b424b

Please sign in to comment.