-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Course reserves are now driven from the Folio data
- Loading branch information
Showing
28 changed files
with
134 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,5 @@ | ||
class CourseReservesController < ApplicationController | ||
include Blacklight::SearchContext | ||
include Blacklight::Configurable | ||
copy_blacklight_config_from(CatalogController) | ||
|
||
def index | ||
facet = "crez_course_info" | ||
p = {} | ||
p[:"facet.field"] = facet | ||
p[:"f.#{facet}.facet.limit"] = "-1" # this implies lexical sort | ||
p[:rows] = 0 | ||
response = blacklight_config.repository.search(p) | ||
course_reserves = [] | ||
response.aggregations.values.first.items.each do |item| | ||
course_reserves << CourseReserves.from_crez_info(item.value) | ||
end | ||
@course_reserves = course_reserves | ||
@course_reserves = CourseReserve.all | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,5 @@ | ||
module CourseReserves | ||
def course_reserves | ||
if self.respond_to?(:[]) | ||
@course_reserves ||= CourseReserves::Processor.new(self) | ||
end | ||
@course_reserves ||= course_ids.present? ? Array(CourseReserve.find(*course_ids)).sort_by(&:course_number) : [] | ||
end | ||
|
||
def self.from_crez_info(course) | ||
CourseInfo.new(*course.split('-|-').map { |c| c.strip }) | ||
end | ||
|
||
private | ||
|
||
class Processor | ||
def initialize(document) | ||
@courses = Array(document[:crez_course_info]).map { |course| CourseReserves.from_crez_info(course) } | ||
end | ||
|
||
def present? | ||
true ? @courses : false | ||
end | ||
|
||
attr_reader :courses | ||
end | ||
|
||
CourseInfo = Data.define(:id, :name, :instructor) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# The store of course reserve data from courses.json | ||
class CourseReserve | ||
FolioCourseInfo = Data.define(:id, :course_number, :name, :instructor) | ||
|
||
class Repository | ||
include Singleton | ||
|
||
def all | ||
@all ||= Folio::Types.courses.map do |id, v| | ||
FolioCourseInfo.new(id:, course_number: v['courseNumber'], | ||
name: v['name'], | ||
instructor: v.dig('courseListingObject', 'instructorObjects').pluck('name')) | ||
end | ||
end | ||
|
||
def find(*ids) | ||
if ids.length == 1 | ||
id = ids.first | ||
all.find { |course| course.id == id } | ||
else | ||
all.select { |course| ids.include?(course.id) } | ||
end | ||
end | ||
end | ||
|
||
def self.all | ||
Repository.instance.all | ||
end | ||
|
||
def self.find(*id) | ||
Repository.instance.find(*id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# The facet value here is a UUID for a folio course. We overide to show a label that a user | ||
# can read. | ||
class FolioCourseFacetItemPresenter < Blacklight::FacetItemPresenter | ||
def constraint_label | ||
CourseReserve.find(value)&.course_number || value | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.