Skip to content

pedrocarmona/tailor_made_example

Repository files navigation

README

Build from scratch

  1. Install rails 6.

  2. Generate application

  $ rails new tailor_made_example -d postgresql -m https://raw.githubusercontent.com/excid3/jumpstart/master/template.rb
  1. Follow blazer gems steps

  2. Add tailor_made

Follow tailor_made Installation steps with webpacker.

  $ bin/rails g tailor_made:dashboard Rating

Add to the routes file:

namespace :tailor_made do
  resources :ratings, only: [:index]
end

Adjust /app/queries/tailor_made/rating_query.rb

module TailorMade
  class RatingQuery < TailorMade::Query
    # creates attr_accessors for dimensions, measures and filters
    include TailorMade::Methods

    dimension :movie_id
    datetime_dimension :rated_at

    measure :average_rating, formula: "AVG(rating)"
    measure :rating_count, formula: "COUNT(rating)"

    def default_dimensions
      [:rated_at_week]
    end

    def default_measures
      [:rating_count, :average_rating]
    end

    def initialize(attributes={})
      super
      @chart ||= :line_chart
    end

    def from
      Movies::Rating.all
    end
  end
end

Database

Same as in blazer-dev

About

example application with tailor made

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published