Skip to content

Depreciated lists - quality score 0 and in special section in results #277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions prefix_finder/frontend/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,10 @@ fieldset {
background-color: #C02942;
}

.card--depreciated header {
background-color: rgba(0, 0, 0, 0.7);;
}

.topbar {
position: relative;
background-color: rgba(0, 0, 0, 0.05);
Expand Down Expand Up @@ -876,6 +880,9 @@ fieldset {
.list-group--fallback h1 {
background-color: #C02942;
}
.list-group--depreciated h1 {
background-color:rgba(0, 0, 0, 0.7);
}

.single-content {
margin-left: auto;
Expand Down
18 changes: 18 additions & 0 deletions prefix_finder/frontend/templates/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ <h1>Fall back identifier sources</h1>
{% endfor %}
</div>
</div>

<div class="list-group list-group--depreciated">
<header class="list-group__header">
<h1>Deprecated lists</h1>
{% if all_results.depreciated %}
<p>The following lists are for reference only. You may see them used in old data.</p>
{% else %}
<p>No deprecated lists meet the search criteria.</p>
{% endif %}
</header>

<div class="list-group__main">
{% for result in all_results.depreciated %}
{% include "results-list.html" with result_class="depreciated" %}
{% endfor %}
</div>
</div>

</div>
</main>
{% endblock %}
45 changes: 26 additions & 19 deletions prefix_finder/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,29 @@ def augment_quality(schemas, org_id_lists):
for prefix in org_id_lists:
quality = 0
quality_explained = {}
for item in (prefix.get('data', {}).get('availability') or []):
value = availabilty_score.get(item)
if value:
quality += value
quality_explained["Availability: " + availabilty_names[item]] = value
else:
print('No availiablity type {}. Found in code {}'.format(item, prefix['code']))

if prefix['data'].get('licenseStatus'):
quality += license_score[prefix['data']['licenseStatus']]
quality_explained["License: " + license_names[prefix['data']['licenseStatus']]] = license_score[prefix['data']['licenseStatus']]
if prefix.get("deprecated"):
quality_explained["Deprecated"] = 0
else:
for item in (prefix.get('data', {}).get('availability') or []):
value = availabilty_score.get(item)
if value:
quality += value
quality_explained["Availability: " + availabilty_names[item]] = value
else:
print('No availiablity type {}. Found in code {}'.format(item, prefix['code']))

if prefix['data'].get('licenseStatus'):
quality += license_score[prefix['data']['licenseStatus']]
quality_explained["License: " + license_names[prefix['data']['licenseStatus']]] = license_score[prefix['data']['licenseStatus']]

if prefix.get('listType'):
value = listtype_score.get(prefix['listType'])
if value:
quality += value
quality_explained["List type: " + listtype_names[prefix['listType']]] = value
else:
print('No licenseStatus for {}. Found in code {}'.format(prefix['listType'], prefix['code']))
if prefix.get('listType'):
value = listtype_score.get(prefix['listType'])
if value:
quality += value
quality_explained["List type: " + listtype_names[prefix['listType']]] = value
else:
print('No licenseStatus for {}. Found in code {}'.format(prefix['listType'], prefix['code']))

prefix['quality_explained'] = quality_explained
prefix['quality'] = min(quality, 100)
Expand Down Expand Up @@ -316,15 +320,18 @@ def filter_and_score_results(query,use_branch="main"):

all_results = {"suggested": [],
"recommended": [],
"other": []}
"other": [],
"depreciated": [],}

if not indexed:
return all_results

for num, value in enumerate(sorted(indexed.values(), key=lambda k: -(k['relevance'] * 100 + k['quality']))):
add_titles(value)

if (value['relevance'] >= RELEVANCE["SUGGESTED_RELEVANCE_THRESHOLD"]
if (value.get("deprecated")):
all_results['depreciated'].append(value)
elif (value['relevance'] >= RELEVANCE["SUGGESTED_RELEVANCE_THRESHOLD"]
and value['quality'] > RELEVANCE["SUGGESTED_QUALITY_THRESHOLD"]
and not all_results['suggested'] or (all_results['suggested'] and value['relevance'] == all_results['suggested'][0]['relevance'])):
all_results['suggested'].append(value)
Expand Down