Skip to content
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

WIP replace crez_course_info #3821

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 5 additions & 3 deletions app/controllers/course_reserves_controller.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
class CourseReservesController < ApplicationController
include Blacklight::SearchContext
include Blacklight::Configurable
include CourseReserves
copy_blacklight_config_from(CatalogController)

def index
facet = "crez_course_info"
# facet = "crez_course_info"
facet = "courses_json_struct"

p = {}
p[:"facet.field"] = facet
p[:"f.#{facet}.facet.limit"] = "-1" # this implies lexical sort
p[:rows] = 0
response = blacklight_config.repository.search(p)
debugger
course_reserves = []
response.aggregations.values.first.items.each do |item|
course_reserves << CourseInfo.new(item.value)
course_reserves << CourseReserves::CourseInfo.new(item.value)
end
@course_reserves = course_reserves
end
Expand Down
18 changes: 0 additions & 18 deletions app/models/concerns/course_reserves.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,4 @@ def present?

attr_reader :courses
end

class CourseInfo
def initialize(course)
@course = course.split('-|-').map { |c| c.strip }
end

def id
@course[0]
end

def name
@course[1]
end

def instructor
@course[2]
end
end
end
19 changes: 19 additions & 0 deletions app/models/course_reserves/course_info.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module CourseReserves
class CourseInfo
def initialize(course)
@course = course.split('-|-').map { |c| c.strip }
end

def id
@course[0]
end

def name
@course[1]
end

def instructor
@course[2]
end
end
end
1 change: 1 addition & 0 deletions config/solr_configs/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
<!-- the next two facets are not used in SW at this time -->
<field name="crez_dept_facet" type="string" indexed="true" stored="true" multiValued="true" />
<field name="crez_desk_facet" type="string" indexed="true" stored="true" multiValued="true" />
<field name="courses_json_struct" type="string" indexed="true" stored="true" multiValued="true" />

<!-- *************** additional fields for DOR objects ****************** -->
<field name="druid" type="string_punct_stop" indexed="true" stored="true" />
Expand Down
5 changes: 5 additions & 0 deletions spec/fixtures/solr_documents/1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
- "ACCT-212-01-02 -|- Managerial Accounting: Base -|- Rajan, Madhav V."
- "ACCT-212-01-02 -|- Managerial Accounting: Base -|- Reichelstein, Stefan J"
- "ACCT-215-01-02 -|- Managerial Accounting: Accelerated -|- Marinovic Vial, Ivan"
:courses_json_struct:
- '{ "course_name": "Managerial Accounting: Base", "course_id": "ACCT-212-01-02", "instructors": ["Rajan, Madhav V."], "reserve_desk": "LAW-CRES"}'
- '{ "course_name": "Managerial Accounting: Base", "course_id": "ACCT-212-01-02", "instructors": ["Reichelstein, Stefan J"], "reserve_desk": "LAW-CRES"}'
- '{ "course_name": "Managerial Accounting: Accelerated", "course_id": "ACCT-215-01-02", "instructors": ["Marinovic Vial, Ivan"], "reserve_desk": "LAW-CRES"}'

:item_display_struct:
- barcode: '36105217238315'
library: EARTH-SCI
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/solr_documents/2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
:instructor: "McDonald, Ronald"
:crez_course_info:
- "CAT-401-01-01 -|- Emergency Kittenz -|- McDonald, Ronald"
:courses_json_struct:
- '{ "course_name": "Emergency Kittenz", "course_id": "CAT-401-01-01", "instructors": ["McDonald, Ronald"], "reserve_desk": "LAW-CRES"}'
Loading