Compare commits

..

No commits in common. "7f624172941c1e410545c25894b480294ebab3b9" and "8502b780c2a37cb7807c7bb7d48d50f681afaf10" have entirely different histories.

4 changed files with 16 additions and 28 deletions

View file

@ -2,15 +2,20 @@ class AltStylesController < ApplicationController
before_action :support_staff_only, except: [:index] before_action :support_staff_only, except: [:index]
def index def index
@all_series_names = AltStyle.all_series_names @all_alt_styles = AltStyle.includes(:species, :color)
@all_color_names = AltStyle.all_supported_colors.map(&:human_name).sort
@all_species_names = AltStyle.all_supported_species.map(&:human_name).sort @all_colors = @all_alt_styles.map(&:color).uniq.sort_by(&:name)
@all_species = @all_alt_styles.map(&:species).uniq.sort_by(&:name)
@all_series_names = @all_alt_styles.map(&:series_name).uniq.sort
@all_color_names = @all_colors.map(&:human_name)
@all_species_names = @all_species.map(&:human_name)
@series_name = params[:series] @series_name = params[:series]
@color = find_color @color = find_color
@species = find_species @species = find_species
@alt_styles = AltStyle.includes(:color, :species, :swf_assets) @alt_styles = @all_alt_styles.includes(:swf_assets)
@alt_styles.where!(series_name: @series_name) if @series_name.present? @alt_styles.where!(series_name: @series_name) if @series_name.present?
@alt_styles.merge!(@color.alt_styles) if @color @alt_styles.merge!(@color.alt_styles) if @color
@alt_styles.merge!(@species.alt_styles) if @species @alt_styles.merge!(@species.alt_styles) if @species

View file

@ -20,11 +20,7 @@ class AltStyle < ApplicationRecord
where(series_name:, color_id: color.id, species_id: species.id) where(series_name:, color_id: color.id, species_id: species.id)
} }
scope :by_creation_date, -> { scope :by_creation_date, -> {
# HACK: Setting up named time zones in MySQL takes effort, so we assume order("DATE(created_at) DESC")
# it's not Daylight Savings. This will produce slightly incorrect
# sorting when it *is* Daylight Savings, and records happen to be
# created around midnight.
order(Arel.sql("DATE(CONVERT_TZ(created_at, '+00:00', '-08:00')) DESC"))
} }
scope :unlabeled, -> { where(series_name: nil) } scope :unlabeled, -> { where(series_name: nil) }
scope :newest, -> { order(created_at: :desc) } scope :newest, -> { order(created_at: :desc) }
@ -105,18 +101,6 @@ class AltStyle < ApplicationRecord
"<New?>" "<New?>"
end end
def self.all_series_names
distinct.where.not(series_name: nil).pluck(:series_name).sort
end
def self.all_supported_colors
Color.find(distinct.pluck(:color_id))
end
def self.all_supported_species
Species.find(distinct.pluck(:species_id))
end
# For convenience in the console! # For convenience in the console!
def self.find_by_name(color_name, species_name) def self.find_by_name(color_name, species_name)
color = Color.find_by_name(color_name) color = Color.find_by_name(color_name)

View file

@ -34,12 +34,11 @@
selected: @species&.human_name, include_blank: "Species…" selected: @species&.human_name, include_blank: "Species…"
= f.submit "Go", name: nil = f.submit "Go", name: nil
- if @alt_styles.present? = will_paginate @alt_styles, class: "rainbow-pool-pagination"
= will_paginate @alt_styles, class: "rainbow-pool-pagination"
%ul.rainbow-pool-list= render @alt_styles %ul.rainbow-pool-list= render @alt_styles
= will_paginate @alt_styles, class: "rainbow-pool-pagination"
- else = will_paginate @alt_styles, class: "rainbow-pool-pagination"
%p.rainbow-pool-no-results We don't have any styles matching that search.
- content_for :stylesheets do - content_for :stylesheets do
= stylesheet_link_tag "application/breadcrumbs" = stylesheet_link_tag "application/breadcrumbs"

View file

@ -34,7 +34,7 @@
%ui.rainbow-pool-list= render @pet_types %ui.rainbow-pool-list= render @pet_types
= will_paginate @pet_types, class: "rainbow-pool-pagination" = will_paginate @pet_types, class: "rainbow-pool-pagination"
- else - else
%p.rainbow-pool-no-results We don't have any pets matching that search. %p.rainbow-pool-no-results No matching pets found!
- content_for :stylesheets do - content_for :stylesheets do
= stylesheet_link_tag "application/rainbow-pool" = stylesheet_link_tag "application/rainbow-pool"