app/models/page.rb
# NOTE: This page size is "huge" because we don't want pagination for data.
# ...Mainly because it gets complicated quickly. Data rows can be in multiple
# TOC items, and we want to be able to show all of the data in a single TOC
# item. ...which I suppose we could manage by passing in a section id.
# ...Hmmmn. We could. But we haven't been asked to, I'm going to hold off for
# now. (NOTE: If we do that, we're going to need another method to pull in the
# full TOC.)
This page size is "huge" because we don't want pagination for data.
Mainly because it gets complicated quickly. Data rows can be in multiple
TOC items, and we want to be able to show all of the data in a single TOC
item. ...which I suppose we could manage by passing in a section id.
Hmmmn. We could. But we haven't been asked to, I'm going to hold off for
now. (NOTE: If we do that, we're going to need another method to pull in the
full TOC.)
This page size is " huge " because we don ' t want pagination for data . Mainly because it gets complicated quickly . Data rows can be in multiple TOC items and we want to be able to show all of the data in a single TOC item . ... which I suppose we could manage by passing in a section id . Hmmmn . We could . But we haven ' t been asked to I ' m going to hold off for now . ( NOTE : If we do that we ' re going to need another method to pull in the full TOC . )
def data(page = 1, per = 2000)
    return @data[0..per] if @data
    data = TraitBank::Queries.by_page(id, page, per)
    @data_toc_needs_other = false
    @data_toc = data.flat_map do |t|
      next if t[:predicate][:section_ids].nil? 
      secs = t[:predicate][:section_ids].split(",")
      @data_toc_needs_other = true if secs.empty?
      secs.map(&:to_i)
    end.uniq
    @data_toc = Section.where(id: @data_toc) unless @data_toc.empty?
    @data_loaded = true
    @data = data
  end
def data ( page = 1 , per = 2000 ) return @data [ 0 .. per ] if @data data = TraitBank :: Queries . by_page ( id , page , per ) @data_toc_needs_other = false @data_toc = data . flat_map do | t | next if t [ :predicate ] [ :section_ids ] . nil? secs = t [ :predicate ] [ :section_ids ] . split ( "," ) @data_toc_needs_other = true if secs . empty? secs . map ( & :to_i ) end . uniq @data_toc = Section . where ( id : @data_toc ) unless @data_toc . empty? @data_loaded = true @data = data end
NOTE: This page size is "huge" because we don't want pagination for data.
NOTE : This page size is " huge " because we don ' t want pagination for data .
# Usu. test data...
page
<not_specific>
per
<not_specific>