Sha256: 71146daa1dd3bc0350b29e8ddf8b7d85876c6a60172194903f3e16d1e8b87db6

Contents?: true

Size: 1.13 KB

Versions: 62

Compression:

Stored size: 1.13 KB

Contents

module Workarea
  class Metadata::HomePage < Metadata
    # Provides a default value for use as the html page title of
    # the home page using the top selling menus.
    #
    # @example
    #   Shop Men's, Women's, Shoes, and Accessories
    #
    # @return [String]
    #
    def title
      [
        I18n.t('workarea.metadata.shop'),
        top_menus.map(&:name).to_sentence
      ].join(' ')
    end

    # Provides a default value for use as the html content meta
    # tag for the home page using the top selling menus
    #
    # @example
    #   Shop online for a great selection including Men's, Women's,
    #   Shoes, and Accesories
    #
    # @return [String]
    #
    def description
      [
        I18n.t(
          'workarea.metadata.shop_selection',
          name: Workarea.config.site_name
        ),
        top_menus.map(&:name).to_sentence
      ].join(' ')
    end

    private

    def top_menus
      @top_menus ||= Navigation::Menu.all.sort_by do |menu|
        Metrics::MenuByDay
          .by_menu(menu.id)
          .since(Workarea.config.sorting_score_ttl.ago)
          .score(:orders)
      end.reverse
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.4.13 app/queries/workarea/metadata/home_page.rb
workarea-core-3.4.12 app/queries/workarea/metadata/home_page.rb