app/controllers/project_stats_controller.rb
# GET /project_stats/nontrivial_projects.json
# Dataset of nontrivial project entries
# Note that this does NOT take a locale.
# rubocop:disable Metrics/MethodLength
# I "freeze" when I can to prevent some errors - allow that:
# rubocop:disable Style/MethodCalledOnDoEndBlock
GET /project_stats/nontrivial_projects.json
Dataset of nontrivial project entries
Note that this does NOT take a locale.
rubocop:disable Metrics/MethodLength
I "freeze" when I can to prevent some errors - allow that:
rubocop:disable Style/MethodCalledOnDoEndBlock
GET / project_stats / nontrivial_projects . json Dataset of nontrivial project entries Note that this does NOT take a locale . rubocop : disable Metrics / MethodLength I " freeze " when I can to prevent some errors - allow that : rubocop : disable Style / MethodCalledOnDoEndBlock
def nontrivial_projects
    cache_until_next_stat
    stat_data = ProjectStat.select(:created_at, *LEVEL0_GT0_FIELDS)
    dataset =
      ProjectStat::STAT_VALUES_GT0.map do |minimum|
        desired_field = 'percent_ge_' + minimum.to_s
        series_dataset =
          stat_data.reduce({}) do |h, e|
            h.merge(e.created_at => e[desired_field])
          end
        { name: '>=' + minimum.to_s + '%', data: series_dataset }
      end
    render_json_fast dataset
  end
def nontrivial_projects cache_until_next_stat stat_data = ProjectStat . select ( :created_at , * LEVEL0_GT0_FIELDS ) dataset = ProjectStat :: STAT_VALUES_GT0 . map do | minimum | desired_field = 'percent_ge_' + minimum . to_s series_dataset = stat_data . reduce ( { } ) do | h , e | h . merge ( e . created_at => e [ desired_field ] ) end { name : '>=' + minimum . to_s + '%' , data : series_dataset } end render_json_fast dataset end
GET /project_stats/nontrivial_projects.json
Dataset of nontrivial project entries
Note that this does NOT take a locale.
GET / project_stats / nontrivial_projects . json Dataset of nontrivial project entries Note that this does NOT take a locale .
# Ask the database *once* for the data we need, then reorganize it # Show project counts; skip 0% because that makes chart scale unusable