Skip to content

Commit d38b405

Browse files
authored
Merge pull request #308 from MITLibraries/use-250-additional-metadata
Use 250 additional metadata
2 parents 031550e + 849a498 commit d38b405

File tree

69 files changed

+2159
-3456
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2159
-3456
lines changed

app/assets/stylesheets/partials/_results.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
overflow: hidden;
124124
display: -webkit-box;
125125
-webkit-line-clamp: 3;
126+
line-clamp: 3;
126127
-webkit-box-orient: vertical;
127128
text-overflow: ellipsis;
128129
}
@@ -404,4 +405,4 @@
404405
@media (max-width: $bp-screen-md) {
405406
flex-direction: column;
406407
}
407-
}
408+
}

app/helpers/record_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def date_parse(date)
77
date
88
end
99

10-
def date_range(range)
10+
def geo_date_range(range)
1111
return unless range.present?
1212

1313
"#{date_parse(range['gte'])} to #{date_parse(range['lte'])}"

app/models/normalize_primo_record.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,9 @@ def links
115115
end
116116

117117
def citation
118-
return unless @record['pnx']['addata']
118+
return unless @record['pnx']['display']
119119

120-
if @record['pnx']['addata']['volume'].present?
121-
if @record['pnx']['addata']['issue'].present?
122-
"volume #{@record['pnx']['addata']['volume'].join} issue #{@record['pnx']['addata']['issue'].join}"
123-
else
124-
"volume #{@record['pnx']['addata']['volume'].join}"
125-
end
126-
elsif @record['pnx']['addata']['date'].present? && @record['pnx']['addata']['pages'].present?
127-
"#{@record['pnx']['addata']['date'].join}, pp. #{@record['pnx']['addata']['pages'].join}"
128-
end
120+
@record['pnx']['display']['ispartof']&.first
129121
end
130122

131123
def container

app/models/normalize_timdex_record.rb

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def normalize
2424
subjects:,
2525
# TIMDEX-specific fields
2626
content_type:,
27+
date_range:,
2728
dates:,
2829
contributors:,
2930
highlight:,
@@ -34,7 +35,26 @@ def normalize
3435
private
3536

3637
def title
37-
@record['title'] || 'Unknown title'
38+
title = @record['title'] || 'Unknown title'
39+
40+
# The collection identifier is important for ASpace records so we append it to the title
41+
return title unless source == 'MIT ArchivesSpace'
42+
43+
title += " (#{aspace_collection(@record['identifiers'])})"
44+
end
45+
46+
def aspace_collection(identifiers)
47+
relevant_ids = identifiers.map { |id| id['value'] if id['kind'] == 'Collection Identifier' }.compact
48+
49+
# In the highly unlikely event that there is more than one collection identifier, there's something weird going
50+
# on with the record and we should look into it.
51+
if relevant_ids.count > 1
52+
Sentry.set_tags('mitlib.recordId': identifier || 'empty record id')
53+
Sentry.set_tags('mitlib.collection_ids': relevant_ids.join('; '))
54+
Sentry.capture_message('Multiple Collection IDs found in ASpace record')
55+
end
56+
57+
relevant_ids.first
3858
end
3959

4060
def creators
@@ -104,7 +124,7 @@ def links
104124
end
105125

106126
def citation
107-
@record['citation'] || nil
127+
@record['citation']
108128
end
109129

110130
def summary
@@ -130,7 +150,7 @@ def location
130150
def subjects
131151
return [] unless @record['subjects']
132152

133-
@record['subjects'].map { |subject| subject['value'] }
153+
@record['subjects'].flat_map { |subject| subject['value'] }
134154
end
135155

136156
def identifier
@@ -146,6 +166,25 @@ def dates
146166
@record['dates']
147167
end
148168

169+
def date_range
170+
return unless @record['dates']
171+
172+
# Some records have creation or publication dates that are ranges. Extract those here.
173+
relevant_dates = @record['dates'].select do |date|
174+
%w[creation publication].include?(date['kind']) && date['range'].present?
175+
end
176+
177+
# If the record has no creation or publication date, stop here.
178+
return if relevant_dates.empty?
179+
180+
# If the record *does* have more than one creation/pub date, just take the first one. Note: ASpace records often
181+
# have more than one. Sometimes they are duplicates, sometimes they are different. For now we will just take the
182+
# first.
183+
relevant_date = relevant_dates.first
184+
185+
"#{relevant_date['range']['gte']}-#{relevant_date['range']['lte']}"
186+
end
187+
149188
def contributors
150189
@record['contributors']
151190
end

app/models/timdex_search.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ class TimdexSearch < TimdexBase
5050
hits
5151
records {
5252
timdexRecordId
53+
identifiers {
54+
kind
55+
value
56+
}
5357
title
5458
source
5559
contentType
@@ -61,6 +65,10 @@ class TimdexSearch < TimdexBase
6165
dates {
6266
kind
6367
value
68+
range {
69+
gte
70+
lte
71+
}
6472
}
6573
links {
6674
kind
@@ -84,6 +92,11 @@ class TimdexSearch < TimdexBase
8492
}
8593
sourceLink
8694
summary
95+
subjects {
96+
kind
97+
value
98+
}
99+
citation
87100
}
88101
aggregations {
89102
accessToFiles {

app/views/record/_record.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
<ul class="list-dates">
128128
<% @record['dates'].each do |date| %>
129129
<li>
130-
<%= date['kind'] %>: <%= date_parse(date['value']) %><%= date_range(date['range']) %>
130+
<%= date['kind'] %>: <%= date_parse(date['value']) %>
131131
<%= " Note: #{date['note']}" if date['note'].present? %>
132132
</li>
133133
<% end %>

app/views/record/_record_geo.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<ul class="list-dates">
3535
<% @record['dates'].each do |date| %>
3636
<li>
37-
<%= date['kind'] %>: <%= date_parse(date['value']) %><%= date_range(date['range']) %>
37+
<%= date['kind'] %>: <%= date_parse(date['value']) %><%= geo_date_range(date['range']) %>
3838
<%= " Note: #{date['note']}" if date['note'].present? %>
3939
</li>
4040
<% end %>

app/views/search/_result.html.erb

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,44 @@
1010

1111
<p class="pub-info">
1212
<span><%= result[:content_type]&.each { |type| type['value'] }&.join(' ; ') %></span>
13-
<span>
14-
<% result[:dates]&.each do |date| %>
15-
<%= date['value'] if date['kind'] == 'Publication date' %>
16-
<% end %>
17-
</span>
13+
14+
<% if result[:date_range].present? %>
15+
<span><%= result[:date_range] %></span>
16+
<% else %>
17+
<span>
18+
<% result[:dates]&.each do |date| %>
19+
<%= date['value'] if date['kind'] == 'Publication date' %>
20+
<% end %>
21+
</span>
22+
<% end %>
1823
</p>
1924

25+
<%# unclear why TIMDEX is using contributors and Primo is using creators. Should we normalize this? %>
2026
<% if result[:contributors].present? %>
2127
<span class="sr">Contributors: </span>
2228
<ul class="list-inline truncate-list contributors">
2329
<%= render partial: 'shared/contributors', locals: { contributors: result[:contributors] } %>
2430
</ul>
2531
<% end %>
32+
33+
<%# Primo displays citation here. TIMDEX citations probably need work to be useful here %>
34+
35+
<% if result[:subjects].present? %>
36+
<div class="result-subjects truncate-list">
37+
<span class="sr">Subjects: </span>
38+
<ul>
39+
<% result[:subjects].each do |subject| %>
40+
<li><%= subject %></li>
41+
<% end %>
42+
</ul>
43+
</div>
44+
<% end %>
45+
46+
<% if result[:summary].present? %>
47+
<div class="result-summary truncate-list">
48+
<span class="sr">Summary: </span><%= result[:summary] %>
49+
</div>
50+
<% end %>
2651
</div>
2752

2853
<div class="result-highlights use">

app/views/search/_result_primo.html.erb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<span><%= result[:year] %></span>
1818
</p>
1919

20+
<%# unclear why TIMDEX is using contributors and Primo is using creators. Should we normalize this? %>
2021
<% if result[:creators].present? %>
2122
<span class="sr">Contributors: </span>
2223
<ul class="list-inline truncate-list contributors">
@@ -32,6 +33,28 @@
3233
</ul>
3334
<% end %>
3435

36+
<% if result[:citation].present? %>
37+
<div class="result-container">
38+
<span>In: </span><%= result[:citation] %>
39+
</div>
40+
<% end %>
41+
42+
<% if result[:subjects].present? %>
43+
<div class="result-subjects truncate-list">
44+
<span class="sr">Subjects: </span>
45+
<ul>
46+
<% result[:subjects].each do |subject| %>
47+
<li><%= subject %></li>
48+
<% end %>
49+
</ul>
50+
</div>
51+
<% end %>
52+
53+
<% if result[:summary].present? %>
54+
<div class="result-summary truncate-list">
55+
<span class="sr">Summary: </span><%= result[:summary] %>
56+
</div>
57+
<% end %>
3558
</div>
3659

3760
<div class="result-get">
Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,83 @@
11
{
22
"pnx": {
33
"display": {
4-
"title": ["Testing the Limits of Knowledge"],
5-
"creator": ["Smith, John A.", "Jones, Mary B."],
6-
"contributor": ["Brown, Robert C."],
7-
"creationdate": ["2023"],
8-
"type": ["book"],
9-
"description": ["A comprehensive study of testing methodologies"],
10-
"subject": ["Computer Science", "Software Testing"]
4+
"title": [
5+
"Testing the Limits of Knowledge"
6+
],
7+
"creator": [
8+
"Smith, John A.",
9+
"Jones, Mary B."
10+
],
11+
"contributor": [
12+
"Brown, Robert C."
13+
],
14+
"creationdate": [
15+
"2023"
16+
],
17+
"ispartof": [
18+
"Journal of Testing, Vol. 2, Issue 3"
19+
],
20+
"type": [
21+
"book"
22+
],
23+
"description": [
24+
"A comprehensive study of testing methodologies"
25+
],
26+
"subject": [
27+
"Computer Science",
28+
"Software Testing"
29+
]
1130
},
1231
"addata": {
13-
"btitle": ["Complete Guide to Testing"],
14-
"date": ["2023"],
15-
"volume": ["2"],
16-
"issue": ["3"],
17-
"pages": ["123-145"],
18-
"jtitle": ["Journal of Testing"],
19-
"isbn": ["9781234567890", "1234567890"],
20-
"pub": ["MIT Press"],
21-
"doi": ["10.1038/s41567-023-02305-y"],
22-
"pmid": ["22110403"]
32+
"btitle": [
33+
"Complete Guide to Testing"
34+
],
35+
"date": [
36+
"2023"
37+
],
38+
"volume": [
39+
"2"
40+
],
41+
"issue": [
42+
"3"
43+
],
44+
"pages": [
45+
"123-145"
46+
],
47+
"jtitle": [
48+
"Journal of Testing"
49+
],
50+
"isbn": [
51+
"9781234567890",
52+
"1234567890"
53+
],
54+
"pub": [
55+
"MIT Press"
56+
],
57+
"doi": [
58+
"10.1038/s41567-023-02305-y"
59+
],
60+
"pmid": [
61+
"22110403"
62+
]
2363
},
2464
"facets": {
25-
"frbrtype": ["5"],
26-
"frbrgroupid": ["12345"]
65+
"frbrtype": [
66+
"5"
67+
],
68+
"frbrgroupid": [
69+
"12345"
70+
]
2771
},
2872
"search": {
29-
"creationdate": ["2023"]
73+
"creationdate": [
74+
"2023"
75+
]
3076
},
3177
"control": {
32-
"recordid": ["alma991000000001234567"]
78+
"recordid": [
79+
"alma991000000001234567"
80+
]
3381
}
3482
},
3583
"context": "contextual",
@@ -41,10 +89,14 @@
4189
"availabilityStatus": "available"
4290
},
4391
"holding": [
44-
{"location": "Main Library"},
45-
{"location": "Branch Library"}
92+
{
93+
"location": "Main Library"
94+
},
95+
{
96+
"location": "Branch Library"
97+
}
4698
],
4799
"link": [],
48100
"almaOpenurl": "https://na06.alma.exlibrisgroup.com/view/uresolver/01MIT_INST/openurl?param=value"
49101
}
50-
}
102+
}

0 commit comments

Comments
 (0)