Skip to content

Commit

Permalink
'check for id styles for pss clip page' (#2688)
Browse files Browse the repository at this point in the history
* 'check for id styles for pss clip page'

* 'ruboooooooo'
  • Loading branch information
foglabs authored Nov 29, 2023
1 parent 510a75e commit d0731a7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions app/controllers/primary_source_sets_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class PrimarySourceSetsController < OverrideController
include ApplicationHelper
include IdHelper

def index
@all_resource_sets = PrimarySourceSet.all_resource_sets
Expand All @@ -13,10 +14,9 @@ def show
@page_title = @primary_source_set.title

if @primary_source_set.guid
@solr = Solr.instance.connect
resp = @solr.get('select', params: { q: "id:#{@primary_source_set.guid}", fl: 'xml' })
doc = resp['response']['docs'].first if resp['response'] && resp['response']['docs']
redirect_to '/' and return unless doc
doc = find_doc(@primary_source_set.guid)
raise "Record not found with guid #{@primary_source_set.guid}" unless doc

@pbcore = PBCorePresenter.new(doc['xml'])

@transcript_html = @pbcore.transcript_html(@primary_source_set.clip_start, @primary_source_set.clip_end)
Expand All @@ -31,3 +31,18 @@ def show
params[:path] = nil
end
end

private

def find_doc(guid)
doc = nil
@solr = Solr.instance.connect

id_styles(guid).each do |g|
resp = @solr.get('select', params: { q: "id:#{g}", fl: 'xml' })
doc = resp['response']['docs'].first if resp['response'] && resp['response']['docs']
break if doc
end

doc
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


## Guid
cpb-aacip-153-988gtx44
cpb-aacip-153-988gtx44

## Introduction

Expand Down

0 comments on commit d0731a7

Please sign in to comment.