Skip to content

Commit

Permalink
KBMBF-452: #37 Show ratio of oer-content
Browse files Browse the repository at this point in the history
WIP: Fixing license
  • Loading branch information
Robert Meissner committed Jul 18, 2022
1 parent 18ba51d commit b30417a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
22 changes: 11 additions & 11 deletions src/app/api/collections/missing_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,26 +207,26 @@ def missing_attributes_search(
) -> Search:
missing_attribute_filter = {"filter": type_filter[ResourceType.MATERIAL]}

should_filter = {
"should": [
qmatch(**{"collections.path": node_id}),
qmatch(**{"collections.nodeRef.id": node_id}),
]
}
if missing_attribute == LearningMaterialAttribute.LICENSES.path:
license_query = query_missing_material_license().to_dict()["bool"]
missing_attribute_filter.update(**license_query)

should_filter["should"] += [Q(query) for query in license_query["should"]]
license_query.pop("should")
query = {
"minimum_should_match": 1,
"should": [
qmatch(**{"path": node_id}),
qmatch(**{"nodeRef.id": node_id}),
query_missing_material_license(),
],
**should_filter,
**license_query,
**missing_attribute_filter,
}
else:
query = {
"minimum_should_match": 1,
"should": [
qmatch(**{"collections.path": node_id}),
qmatch(**{"collections.nodeRef.id": node_id}),
],
**should_filter,
"must_not": Q("wildcard", **{missing_attribute: {"value": "*"}}),
**missing_attribute_filter,
}
Expand Down
14 changes: 12 additions & 2 deletions tests/unit_tests/crud/test_missing_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_missing_materials_search():

def test_missing_materials_search_license():
dummy_uuid = uuid.uuid4()
dummy_attribute = "properties.commonlicense_key"
dummy_attribute = "properties.ccm:commonlicense_key"
dummy_missing_attribute = missing_attribute_filter[4].value
dummy_maximum_size = 3
search = missing_attributes_search(
Expand All @@ -77,9 +77,19 @@ def test_missing_materials_search_license():
"should": [
{"match": {"collections.path": dummy_uuid}},
{"match": {"collections.nodeRef.id": dummy_uuid}},
{
"terms": {
dummy_attribute
+ ".keyword": [
"UNTERRICHTS_UND_LEHRMEDIEN",
"NONE",
"",
]
}
},
{"bool": {"must_not": [{"exists": {"field": dummy_attribute}}]}},
],
"minimum_should_match": 1,
"must_not": [{"wildcard": {dummy_attribute: {"value": "*"}}}],
}
},
"from": 0,
Expand Down

0 comments on commit b30417a

Please sign in to comment.