This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT p.id, par.first_name ||' '|| par.last_name AS partners_name, | |
| c.first_name ||' '|| c.last_name AS customers_name, | |
| en_c.first_name ||' '|| en_c.last_name AS enquiry_customers_name, | |
| coalesce(par.first_name||par.last_name, c.first_name||c.last_name, en_c.first_name||en_c.last_name, 'test') AS result | |
| FROM passengers p | |
| LEFT JOIN customers c ON p.customer_id = c.id | |
| LEFT JOIN partners par ON p.partner_id = par.id | |
| JOIN enquiries e ON p.enquiry_id = e.id | |
| JOIN customers en_c ON e.customer_id = en_c.id | |
| ORDER BY coalesce(par.first_name||' '||par.last_name, c.first_name||' '||c.last_name, en_c.first_name||' '||en_c.last_name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| = form_tag forecasts_path, method: :get do | |
| .row.forecast-row.flex-container.space-between | |
| .forecast-bar | |
| .title | |
| | Use data since: | |
| = text_field_tag :data_start, @data_dates.first, class: 'form-control' | |
| .forecast-bar | |
| .title | |
| | Cruise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title><%= title %></title> | |
| <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Sail CRM" %>"> | |
| <%= favicon_link_tag %> | |
| <%= javascript_include_tag 'forecasts' %> | |
| <%= stylesheet_link_tag 'forecasts', media: 'all' %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ForecastsController < ApplicationController | |
| include ForecastsHelper | |
| layout 'forecasts' | |
| before_action :set_dates, :set_chart_data, only: [:index, :table] | |
| def index | |
| respond_to do |format| | |
| format.html | |
| format.csv { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LinearRegression | |
| def initialize(hash) | |
| x = hash.keys | |
| y = hash.values | |
| @xs, @ys = x, y | |
| if @xs.length != @ys.length | |
| raise "Unbalanced data. xs need to be same length as ys" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "csv" | |
| class ForecastCSV < Struct.new(:forecast, :current_user_id) | |
| def perform | |
| data = forecast.detect{|f| f[:name] == 'forecast'}[:data] | |
| path = "tmp/Forecast-#{Time.now.strftime("%d-%m-%Y %I:%M-%S")}.csv" | |
| CSV.open(path, "w+") do |csv| | |
| csv << ["date", "value"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ForecastGenerator | |
| class Seasoned | |
| attr_reader :data, :data_trend, :forecast | |
| def initialize(data) | |
| @data = data | |
| @coeffs = get_coefficients | |
| @trend_params = trend_params | |
| @data_trend = trend(@data.count) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .chart-block | |
| h2 | |
| = "Initial data for #{@data_dates.count} months" | |
| .chart | |
| = line_chart @data_chart | |
| .chart-block | |
| h2 | |
| = "Forecast for #{@months_count} months" | |
| .chart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Forecast < ActiveRecord::Base | |
| include ForecastGenerator | |
| belongs_to :cruise | |
| serialize :result, JSON | |
| def generate(cruise = nil, length, initial_data_length) | |
| length ||= defaults[:length_months] | |
| initial_data_length ||= defaults[:initial_data_length] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - № месяца и шрифт в таблицах | |
| - Интервал 1.15 | |
| - Изменить названия таблиц | |
| - формулы точки вместо умножения | |
| - отступ у хвоста в заголовках | |
| - структуру перенести просто в выбор PO | |
| - Фишер в методе батина | |
| - прогноз на другие круизы | |
| - БД |