-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KBMBF-452: #37 Show ratio of oer-content
WIP: showing overall OER in table
- Loading branch information
Robert Meissner
committed
Jul 19, 2022
1 parent
3b129af
commit 1637950
Showing
10 changed files
with
72 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import uuid | ||
|
||
from app.api.collections.counts import ( | ||
_AGGREGATION_NAME, | ||
AggregationMappings, | ||
collection_counts_search, | ||
) | ||
|
||
|
||
def oer_ratio(node_id: uuid.UUID) -> int: | ||
oer_statistics = collection_counts_search(node_id, AggregationMappings.license) | ||
response = oer_statistics.execute() | ||
oer_elements = 0 | ||
oer_total = 0 | ||
oer_license = ["CC_0", "PDM", "CC_BY", "CC_BY_SA"] | ||
for data in response.aggregations[_AGGREGATION_NAME].buckets: | ||
for bucket in data["facet"]["buckets"]: | ||
oer_total += bucket["doc_count"] | ||
if bucket["key"] in oer_license: | ||
oer_elements += bucket["doc_count"] | ||
|
||
return round((oer_elements / oer_total) * 100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters