Skip to content

Commit

Permalink
Install standard and apply automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmorrison committed Mar 31, 2022
1 parent 8aaaa92 commit 4aa051d
Show file tree
Hide file tree
Showing 81 changed files with 531 additions and 532 deletions.
2 changes: 0 additions & 2 deletions .rubocop.yml

This file was deleted.

6 changes: 3 additions & 3 deletions Capfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load 'deploy'
load "deploy"
# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks
# load 'deploy/assets'
load "config/deploy" # remove this line to skip loading any of the default tasks
54 changes: 27 additions & 27 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
source 'https://rubygems.org'
source "https://rubygems.org"

ruby "3.1.1"

gem 'rails', '~> 7.0.1'
gem "rails", "~> 7.0.1"

gem 'pg'
gem "pg"

# Assets
gem 'cssbundling-rails'
gem 'importmap-rails'
gem 'propshaft'
gem "cssbundling-rails"
gem "importmap-rails"
gem "propshaft"

gem 'actionpack-page_caching'
gem 'active_model_serializers'
gem 'bigdecimal'
gem 'pagy'
gem 'rails-observers'
gem "actionpack-page_caching"
gem "active_model_serializers"
gem "bigdecimal"
gem "pagy"
gem "rails-observers"

gem 'oj'
gem "oj"

group :development do
gem 'capistrano', '< 3.0'
gem 'derailed'
gem 'stackprof'
gem "capistrano", "< 3.0"
gem "derailed"
gem "stackprof"
end

group :test, :development do
gem 'rspec-rails'
gem 'capybara'
gem 'nokogiri', require: false
gem 'poltergeist'
gem 'domino'
gem 'factory_bot_rails'
gem 'rubocop', require: false
gem 'pry'
gem "rspec-rails"
gem "capybara"
gem "nokogiri", require: false
gem "poltergeist"
gem "domino"
gem "factory_bot_rails"
gem "standard", require: false
gem "pry"
end

group :no_require do
gem 'faye'
gem "faye"
# This gem is normally pulled in via faye, but cuurrent version
# breaks with --enable=frozen-string-literal so remove when version > 0.7.5
# https://github.com/faye/websocket-driver-ruby/pull/85
gem "websocket-driver", github: "faye/websocket-driver-ruby"
gem 'thin'
gem 'raindrops'
gem 'god'
gem "thin"
gem "raindrops"
gem "god"
end
12 changes: 9 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ GEM
oj (3.13.11)
pagy (5.10.1)
activesupport
parallel (1.22.0)
parallel (1.22.1)
parser (3.1.1.0)
ast (~> 2.4.1)
pg (1.3.4)
Expand Down Expand Up @@ -287,7 +287,7 @@ GEM
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.11.0)
rubocop (1.26.1)
rubocop (1.26.0)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
Expand All @@ -298,9 +298,15 @@ GEM
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.16.0)
parser (>= 3.1.1.0)
rubocop-performance (1.13.3)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.11.0)
ruby-statistics (3.0.0)
stackprof (0.2.19)
standard (1.9.0)
rubocop (= 1.26.0)
rubocop-performance (= 1.13.3)
strscan (3.0.1)
thin (1.8.1)
daemons (~> 1.0, >= 1.0.9)
Expand Down Expand Up @@ -344,8 +350,8 @@ DEPENDENCIES
rails-observers
raindrops
rspec-rails
rubocop
stackprof
standard
thin
websocket-driver!

Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require File.expand_path("../config/application", __FILE__)

Bender::Application.load_tasks
4 changes: 2 additions & 2 deletions app/controllers/activity_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class ActivityController < ApplicationController
def recent
pours = Pour.where('volume IS NOT NULL').order('created_at desc').limit(params[:limit] || 10)
pours = Pour.where("volume IS NOT NULL").order("created_at desc").limit(params[:limit] || 10)

render json: append_data(pours).to_json
end

def user_recent
pours = Pour.where('volume IS NOT NULL AND user_id = ?', params[:user_id]).order('created_at desc').limit(params[:limit] || 10)
pours = Pour.where("volume IS NOT NULL AND user_id = ?", params[:user_id]).order("created_at desc").limit(params[:limit] || 10)

render json: append_data(pours).to_json
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/kegs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Admin::KegsController < ApplicationController
def index
@kegs = Keg.order('started_at DESC NULLS FIRST')
@kegs = Keg.order("started_at DESC NULLS FIRST")
end

def show
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def update
@user.attributes = user_params

if @user.save
flash[:success] = 'User updated'
flash[:success] = "User updated"
redirect_to admin_users_path
else
render :edit
Expand All @@ -34,7 +34,7 @@ def new
def create
@user = User.new(user_params)
if @user.save
flash[:success] = 'User created'
flash[:success] = "User created"
redirect_to admin_users_path
else
render :new
Expand Down
1 change: 0 additions & 1 deletion app/controllers/api/v1/auth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def create
def auth_params
params.require(:rfid)
end

end
end
end
4 changes: 2 additions & 2 deletions app/controllers/api/v1/kegs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module API
module V1
class KegsController < ApplicationController
def index
@kegs = Keg.order('started_at DESC NULLS FIRST')
@kegs = @kegs.where(active: true) if params[:active] == 'true'
@kegs = Keg.order("started_at DESC NULLS FIRST")
@kegs = @kegs.where(active: true) if params[:active] == "true"
render json: @kegs.preload(:beer_tap).as_json(include: :beer_tap)
end

Expand Down
16 changes: 8 additions & 8 deletions app/controllers/api/v1/pours_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module API
module V1
class PoursController < ApplicationController
def index
@pours = Pour.for_listing.except(:includes).
between_dates(start_time: start_time, end_time: end_time)
@pours = Pour.for_listing.except(:includes)
.between_dates(start_time: start_time, end_time: end_time)

render json: Oj.dump(@pours.as_json(except: [:sensor_ticks, :updated_at]), mode: :compat)
end
Expand All @@ -12,17 +12,17 @@ def show
pours = Pour.between_dates(start_time: start_time, end_time: end_time)
case params[:id]
when "by_beer"
data = pours.joins(:keg).where.not(started_at: nil).
group("kegs.name, pour_date").order("kegs.name, pour_date").
pluck(Arel.sql("kegs.name AS name, date_trunc('day', pours.started_at::TIMESTAMPTZ AT TIME ZONE '#{Time.zone.tzinfo.canonical_identifier}') AS pour_date, count(pours.id) AS pour_count")).
each.with_object({}) do |pour, out|
data = pours.joins(:keg).where.not(started_at: nil)
.group("kegs.name, pour_date").order("kegs.name, pour_date")
.pluck(Arel.sql("kegs.name AS name, date_trunc('day', pours.started_at::TIMESTAMPTZ AT TIME ZONE '#{Time.zone.tzinfo.canonical_identifier}') AS pour_date, count(pours.id) AS pour_count"))
.each.with_object({}) do |pour, out|
(out[pour[0]] ||= []) << [pour[1].to_date, pour[2]]
end

render json: Oj.dump(data.as_json, mode: :compat)
when "by_user"
data = pours.joins(:user).
group("users.name, users.email").select("users.name", "users.email, SUM(pours.volume) AS volume")
data = pours.joins(:user)
.group("users.name, users.email").select("users.name", "users.email, SUM(pours.volume) AS volume")
render json: Oj.dump(data.as_json, mode: :compat)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def user_params
end
end
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/homepage_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class HomepageController < ApplicationController
def index
@beer_taps = BeerTap.order(:display_order)
@pours = Pour.where('volume IS NOT NULL').order('created_at desc').limit(@beer_taps.size * 3)
@pours = Pour.where("volume IS NOT NULL").order("created_at desc").limit(@beer_taps.size * 3)
end
end
4 changes: 2 additions & 2 deletions app/controllers/kegs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class KegsController < ApplicationController
def index
@kegs = Keg.order('started_at DESC NULLS FIRST')
@kegs = @kegs.where(active: true) if params[:active] == 'true'
@kegs = Keg.order("started_at DESC NULLS FIRST")
@kegs = @kegs.where(active: true) if params[:active] == "true"
end

def show
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/pours_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ def index
end

def new
@users = User.where(['name != ?', 'Guest']).order(:name)
@users = User.where(["name != ?", "Guest"]).order(:name)
end

def create
user = User.where("id = ? OR rfid = ?", params[:user_id], params[:user_rfid]).first! if params[:user_id] != '0'
user = User.where("id = ? OR rfid = ?", params[:user_id], params[:user_rfid]).first! if params[:user_id] != "0"
unless user.pours_remaining?
render status: :forbidden, plain: "Insufficient credits remaining"
return
Expand All @@ -27,7 +27,7 @@ def show

def edit
@pour = Pour.find(params[:id])
@users = User.where(['name != ?', 'Guest']).order(:name)
@users = User.where(["name != ?", "Guest"]).order(:name)
end

def update
Expand All @@ -42,7 +42,7 @@ def update

def volume
@pour = Pour.find(params[:pour_id])
output = @pour.volume ? "You have poured <span>#{'%0.2f' % @pour.volume} oz." : ''
output = @pour.volume ? "You have poured <span>#{"%0.2f" % @pour.volume} oz." : ""
render text: output, layout: false
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/temperature_sensors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def readings

sensor = TemperatureSensor.find(params[:sensor_id])
start_time = Time.at(params[:start_timestamp].to_i)
end_time = start_time + params[:duration].to_i
end_time = start_time + params[:duration].to_i

render json: Oj.dump(sensor.temp_data(start_time, end_time))
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def new
def create
@user = User.new(user_params)
if @user.save
flash[:success] = 'User created'
flash[:success] = "User created"
redirect_to root_path
else
render :new
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module ApplicationHelper
include Pagy::Frontend

def errors_for(model, separator='<br>'.html_safe)
messages = ''.html_safe
def errors_for(model, separator = "<br>".html_safe)
messages = "".html_safe
model.errors.full_messages.each do |msg|
messages << msg
messages << separator
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/homepage_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module HomepageHelper
def homepage_tap_header(tap)
header = tap.name.html_safe
header += ': '
header += ": "
header + if keg = tap.active_keg
link_to keg.name, keg
else
'Offline'
"Offline"
end
end
end
2 changes: 1 addition & 1 deletion app/helpers/pours_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def last_pour(user)
if pour_at = user.last_pour_at
"Last activity: #{I18n.l(pour_at, format: :norm)}"
else
'No activity yet'
"No activity yet"
end
end
end
Loading

0 comments on commit 4aa051d

Please sign in to comment.