Skip to content

Commit c085b95

Browse files
committed
Depreciated lists - quality score 0 and in special section in results
#277
1 parent 2d8db34 commit c085b95

File tree

3 files changed

+51
-19
lines changed

3 files changed

+51
-19
lines changed

prefix_finder/frontend/static/css/main.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,10 @@ fieldset {
538538
background-color: #C02942;
539539
}
540540

541+
.card--depreciated header {
542+
background-color: rgba(0, 0, 0, 0.7);;
543+
}
544+
541545
.topbar {
542546
position: relative;
543547
background-color: rgba(0, 0, 0, 0.05);
@@ -876,6 +880,9 @@ fieldset {
876880
.list-group--fallback h1 {
877881
background-color: #C02942;
878882
}
883+
.list-group--depreciated h1 {
884+
background-color:rgba(0, 0, 0, 0.7);
885+
}
879886

880887
.single-content {
881888
margin-left: auto;

prefix_finder/frontend/templates/results.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ <h1>Fall back identifier sources</h1>
5959
{% endfor %}
6060
</div>
6161
</div>
62+
63+
<div class="list-group list-group--depreciated">
64+
<header class="list-group__header">
65+
<h1>Deprecated lists</h1>
66+
{% if all_results.depreciated %}
67+
<p>The following lists are for reference only. You may see them used in old data.</p>
68+
{% else %}
69+
<p>No deprecated lists meet the search criteria.</p>
70+
{% endif %}
71+
</header>
72+
73+
<div class="list-group__main">
74+
{% for result in all_results.depreciated %}
75+
{% include "results-list.html" with result_class="depreciated" %}
76+
{% endfor %}
77+
</div>
78+
</div>
79+
6280
</div>
6381
</main>
6482
{% endblock %}

prefix_finder/frontend/views.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,25 +119,29 @@ def augment_quality(schemas, org_id_lists):
119119
for prefix in org_id_lists:
120120
quality = 0
121121
quality_explained = {}
122-
for item in (prefix.get('data', {}).get('availability') or []):
123-
value = availabilty_score.get(item)
124-
if value:
125-
quality += value
126-
quality_explained["Availability: " + availabilty_names[item]] = value
127-
else:
128-
print('No availiablity type {}. Found in code {}'.format(item, prefix['code']))
129122

130-
if prefix['data'].get('licenseStatus'):
131-
quality += license_score[prefix['data']['licenseStatus']]
132-
quality_explained["License: " + license_names[prefix['data']['licenseStatus']]] = license_score[prefix['data']['licenseStatus']]
123+
if prefix.get("deprecated"):
124+
quality_explained["Deprecated"] = 0
125+
else:
126+
for item in (prefix.get('data', {}).get('availability') or []):
127+
value = availabilty_score.get(item)
128+
if value:
129+
quality += value
130+
quality_explained["Availability: " + availabilty_names[item]] = value
131+
else:
132+
print('No availiablity type {}. Found in code {}'.format(item, prefix['code']))
133+
134+
if prefix['data'].get('licenseStatus'):
135+
quality += license_score[prefix['data']['licenseStatus']]
136+
quality_explained["License: " + license_names[prefix['data']['licenseStatus']]] = license_score[prefix['data']['licenseStatus']]
133137

134-
if prefix.get('listType'):
135-
value = listtype_score.get(prefix['listType'])
136-
if value:
137-
quality += value
138-
quality_explained["List type: " + listtype_names[prefix['listType']]] = value
139-
else:
140-
print('No licenseStatus for {}. Found in code {}'.format(prefix['listType'], prefix['code']))
138+
if prefix.get('listType'):
139+
value = listtype_score.get(prefix['listType'])
140+
if value:
141+
quality += value
142+
quality_explained["List type: " + listtype_names[prefix['listType']]] = value
143+
else:
144+
print('No licenseStatus for {}. Found in code {}'.format(prefix['listType'], prefix['code']))
141145

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

317321
all_results = {"suggested": [],
318322
"recommended": [],
319-
"other": []}
323+
"other": [],
324+
"depreciated": [],}
320325

321326
if not indexed:
322327
return all_results
323328

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

327-
if (value['relevance'] >= RELEVANCE["SUGGESTED_RELEVANCE_THRESHOLD"]
332+
if (value.get("deprecated")):
333+
all_results['depreciated'].append(value)
334+
elif (value['relevance'] >= RELEVANCE["SUGGESTED_RELEVANCE_THRESHOLD"]
328335
and value['quality'] > RELEVANCE["SUGGESTED_QUALITY_THRESHOLD"]
329336
and not all_results['suggested'] or (all_results['suggested'] and value['relevance'] == all_results['suggested'][0]['relevance'])):
330337
all_results['suggested'].append(value)

0 commit comments

Comments
 (0)