Skip to content

Commit

Permalink
Added degree level to dropdown, created filtering test (#277)
Browse files Browse the repository at this point in the history
* Added degree level to dropdown, created filtering test

* update caniuse browser list

* add degree information to mods fixture and related tests

---------

Co-authored-by: Nathan Alexander Walker <[email protected]>
Co-authored-by: JackBlackLight <[email protected]>
  • Loading branch information
3 people authored Jan 5, 2024
1 parent bcaccd4 commit 2088852
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/forms/usage_statistics_reports_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class UsageStatisticsReportsForm < FormObject
'Resource Type' => SolrDocument.field_semantics[:resource_type],
'Organization' => SolrDocument.field_semantics[:organization],
'Department' => SolrDocument.field_semantics[:department],
'Degree Level' => SolrDocument.field_semantics[:degree_level],
'Series' => SolrDocument.field_semantics[:columbia_series],
'Non CU Series' => SolrDocument.field_semantics[:non_columbia_series],
'CUL DOI' => SolrDocument.field_semantics[:id]
Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_05_18_134528) do
ActiveRecord::Schema.define(version: 2022_12_08_202313) do

create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
Expand Down
35 changes: 35 additions & 0 deletions spec/academic_commons/metrics/usage_statistics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

RSpec.describe AcademicCommons::Metrics::UsageStatistics do
let(:uni) { 'abc123' }
let(:degree_level) { 'Doctoral' }
let(:item_identifier) { '10.7916/ALICE' }
let(:item_fedora_pid) { 'actest:1' }
let(:other_item_identifier) { '10.7916/TESTDOC5' }
Expand Down Expand Up @@ -102,12 +103,33 @@
)
end

let(:item_by_degree_level_params) do
{
rows: 100_000, sort: 'title_sort asc', q: nil, page: 1,
fq: ["degree_level_name_ssim:\"#{degree_level}\"", 'has_model_ssim:"info:fedora/ldpd:ContentAggregator"'],
fl: 'title_ssi,id,cul_doi_ssi,fedora3_pid_ssi,publisher_doi_ssi,genre_ssim,record_creation_dtsi,object_state_ssi,free_to_read_start_date_ssi'
}
end
let(:item_by_degree_level_response) do
wrap_solr_response_data(
'response' => {
'docs' => [
{ 'id' => item_identifier, 'title_ssi' => 'First Test Document', 'object_state_ssi' => 'A', 'record_creation_dtsi' => '2018-08-07T03:40:22Z',
'cul_doi_ssi' => item_identifier, 'fedora3_pid_ssi' => item_fedora_pid, 'publisher_doi_ssi' => '', 'genre_ssim' => '', 'degree_level_name_ssim' => 'Doctoral' },
{ 'id' => other_item_identifier, 'title_ssi' => 'Second Test Document', 'object_state_ssi' => 'A', 'record_creation_dtsi' => '2018-08-07T03:40:22Z',
'cul_doi_ssi' => other_item_identifier, 'fedora3_pid_ssi' => other_item_fedora_pid, 'publisher_doi_ssi' => '', 'genre_ssim' => '', 'degree_level_name_ssim' => 'Doctoral' }
]
}
)
end

before do
allow(Blacklight.default_index).to receive(:search).with(any_by_author_params).and_return(any_by_author_response)
allow(Blacklight.default_index).to receive(:search).with(item_by_author_params).and_return(item_by_author_response)
allow(Blacklight.default_index).to receive(:search).with(assets_for_item_params).and_return(assets_for_item_response)
allow(Blacklight.default_index).to receive(:search).with(assets_for_other_item_params).and_return(assets_for_other_item_response)
allow(Blacklight.default_index).to receive(:search).with(list_items_params).and_return(list_items_response)
allow(Blacklight.default_index).to receive(:search).with(item_by_degree_level_params).and_return(item_by_degree_level_response)
end

describe '.new' do
Expand Down Expand Up @@ -226,6 +248,19 @@
expect(usage_stats.total_for(Statistic::DOWNLOAD, :lifetime)).to be 1
end
end

context 'when requesting stats for degree level' do
subject(:usage_stats) do
described_class.new(
solr_params: item_by_degree_level_params,
include_streaming: true
).calculate_lifetime
end

it 'returns correct results' do
expect(subject.map(&:document).map(&:to_h)).to eq item_by_degree_level_response.documents.map(&:to_h)
end
end
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/api/v1/record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
'columbia_series' => [],
'created_at' => '2017-09-14T16:31:33Z',
'date' => '1865',
'degree_discipline' => nil,
'degree_grantor' => nil,
'degree_level' => nil,
'degree_name' => nil,
'degree_discipline' => 'Disciplinary Studies',
'degree_grantor' => 'The Grantonator',
'degree_level' => 'Doctoral',
'degree_name' => 'Ph.D.',
'department' => ['Bucolic Literary Society.'],
'embargo_end' => nil,
'id' => '10.7916/ALICE',
Expand Down
15 changes: 15 additions & 0 deletions spec/fixtures/desc_metadata/to_solr.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@
"start_page_ssi": "1",
"end_page_ssi": "69",
"date_ssi": "June 2008",
"degree_discipline_ssim": [
"Disciplinary Studies"
],
"degree_grantor_ssim": [
"The Grantonator"
],
"degree_level_name_ssim": [
"Doctoral"
],
"degree_level_ssim": [
"2"
],
"degree_name_ssim": [
"Ph.D."
],
"book_journal_title_ssi": "Project Gutenberg",
"book_journal_title_q": [
"Project Gutenberg"
Expand Down
9 changes: 9 additions & 0 deletions spec/fixtures/fedora_objs/mods.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
<mods:dateIssued encoding="w3cdtf">1865</mods:dateIssued>
</mods:originInfo>

<mods:extension>
<mods:degree>
<mods:name type="text">Ph.D.</mods:name>
<mods:grantor type="text">The Grantonator</mods:grantor>
<mods:discipline type="text">Disciplinary Studies</mods:discipline>
<mods:level type="text">2</mods:level>
</mods:degree>
</mods:extension>

<mods:language>
<mods:languageTerm type="text">English</mods:languageTerm>
</mods:language>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/oai_xml/list_records_response.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<header>
<identifier>oai:academiccommons.columbia.edu:10.7916/ALICE</identifier>
<datestamp>2017-09-14T16:31:33Z</datestamp>
<setSpec>degree_level:Doctoral</setSpec>
</header>
<metadata>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1905,9 +1905,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"

caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001280:
version "1.0.30001280"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001280.tgz#066a506046ba4be34cde5f74a08db7a396718fb7"
integrity sha512-kFXwYvHe5rix25uwueBxC569o53J6TpnGu0BEEn+6Lhl2vsnAumRFWEBhDft1fwyo6m1r4i+RqA4+163FpeFcA==
version "1.0.30001574"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001574.tgz"
integrity sha512-BtYEK4r/iHt/txm81KBudCUcTy7t+s9emrIaHqjYurQ10x71zJ5VQ9x1dYPcz/b+pKSp4y/v1xSI67A+LzpNyg==

case-sensitive-paths-webpack-plugin@^2.4.0:
version "2.4.0"
Expand Down

0 comments on commit 2088852

Please sign in to comment.