Browse Source

Fix years

pull/90/head
Angel Aviel Domaoan 4 years ago
parent
commit
777784b20c
  1. 4
      app/components/document_advanced_search_component.rb
  2. 4
      app/controllers/api/jurisprudences_controller.rb
  3. 4
      app/controllers/decisions_controller.rb

4
app/components/document_advanced_search_component.rb

@ -6,8 +6,8 @@ class DocumentAdvancedSearchComponent < BaseComponent
end end
def years def years
start_year = Cdao::Jurisprudence.order(year: :asc).first(10).compact.map(&:year).uniq.first || "1900" start_year = Cdao::Jurisprudence.order(year: :asc).first(10).map(&:year).compact.uniq.first || "1900"
end_year = Cdao::Jurisprudence.order(year: :desc).last(10).compact.map(&:year).uniq.last || Time.zone.today.year end_year = Cdao::Jurisprudence.order(year: :desc).last(10).map(&:year).compact.uniq.last || Time.zone.today.year
(start_year..end_year).entries.reverse (start_year..end_year).entries.reverse
end end
end end

4
app/controllers/api/jurisprudences_controller.rb

@ -19,8 +19,8 @@ module Api
def years def years
authorize! :index, Cdao::Jurisprudence authorize! :index, Cdao::Jurisprudence
start_year = Cdao::Jurisprudence.order(year: :asc).first(10).compact.map(&:year).uniq.first || "1900" start_year = Cdao::Jurisprudence.order(year: :asc).first(10).map(&:year).compact.uniq.first || "1900"
end_year = Cdao::Jurisprudence.order(year: :desc).last(10).compact.map(&:year).uniq.last || Time.zone.today.year end_year = Cdao::Jurisprudence.order(year: :desc).last(10).map(&:year).compact.uniq.last || Time.zone.today.year
@years = (start_year..end_year).entries.reverse @years = (start_year..end_year).entries.reverse
respond_with @years respond_with @years

4
app/controllers/decisions_controller.rb

@ -10,8 +10,8 @@ class DecisionsController < ApplicationController
@jurisprudences = search.results @jurisprudences = search.results
start_year = Cdao::Jurisprudence.order(year: :asc).first(10).compact.map(&:year).uniq.first || "1900" start_year = Cdao::Jurisprudence.order(year: :asc).first(10).map(&:year).compact.uniq.first || "1900"
end_year = Cdao::Jurisprudence.order(year: :desc).last(10).compact.map(&:year).uniq.last || Time.zone.today.year end_year = Cdao::Jurisprudence.order(year: :desc).last(10).map(&:year).compact.uniq.last || Time.zone.today.year
@years = (start_year..end_year).entries.reverse @years = (start_year..end_year).entries.reverse
respond_to do |format| respond_to do |format|

Loading…
Cancel
Save