Class: Krikri::ValidationReport
- Inherits:
-
Object
- Object
- Krikri::ValidationReport
- Defined in:
- app/models/krikri/validation_report.rb
Constant Summary collapse
- REQUIRED_FIELDS =
['dataProvider_providedLabel', 'isShownAt_id', 'preview_id', 'sourceResource_rights', 'sourceResource_title', 'sourceResource_type_id']
Instance Attribute Summary collapse
-
#page ⇒ Object
Returns the value of attribute page.
-
#provider_id ⇒ Object
Returns the value of attribute provider_id.
-
#rows ⇒ Object
Returns the value of attribute rows.
Instance Method Summary collapse
-
#all ⇒ Array<Blacklight::SolrResponse::Facets::FacetField>
A report for missing values in each of the ‘REQUIRED_FIELDS`.
- #find(id) ⇒ Blacklight::SolrResponse
Instance Attribute Details
#page ⇒ Object
Returns the value of attribute page.
3 4 5 |
# File 'app/models/krikri/validation_report.rb', line 3 def page @page end |
#provider_id ⇒ Object
Returns the value of attribute provider_id.
3 4 5 |
# File 'app/models/krikri/validation_report.rb', line 3 def provider_id @provider_id end |
#rows ⇒ Object
Returns the value of attribute rows.
3 4 5 |
# File 'app/models/krikri/validation_report.rb', line 3 def rows @rows end |
Instance Method Details
#all ⇒ Array<Blacklight::SolrResponse::Facets::FacetField>
Returns a report for missing values in each of the ‘REQUIRED_FIELDS`.
22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/krikri/validation_report.rb', line 22 def all query_params = { :rows => 0, 'facet.field' => REQUIRED_FIELDS, 'facet.mincount' => 10000000, 'facet.missing' => true } query_params[:fq] = "provider_id:\"#{provider_uri}\"" if provider_id.present? Krikri::SolrResponseBuilder.new(query_params).response.facets end |
#find(id) ⇒ Blacklight::SolrResponse
TODO:
possibly make better use of blacklight controllers? This currently assumes that the default pagination is 10. Anything else will cause trouble.
53 54 55 56 57 58 59 60 61 62 |
# File 'app/models/krikri/validation_report.rb', line 53 def find(id) query_params = { :qt => 'standard', :q => "-#{id}:[* TO *]" } query_params[:rows] = @rows.present? ? @rows : '10' query_params[:fq] = "provider_id:\"#{provider_uri}\"" if provider_id.present? multiplier = @rows ? @rows.to_i : 10 query_params[:start] = ((@page.to_i - 1) * multiplier) if @page.present? Krikri::SolrResponseBuilder.new(query_params).response end |