Skip to content

Commit

Permalink
Merge 18ae7e4 into 88baa03
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot-preview[bot] committed Sep 12, 2019
2 parents 88baa03 + 18ae7e4 commit 89dc568
Show file tree
Hide file tree
Showing 15 changed files with 156 additions and 118 deletions.
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ AllCops:
- 'bin/**'
- 'db/schema.rb'
- 'vendor/**'
TargetRubyVersion: 2.3
TargetRailsVersion: 5.1
TargetRubyVersion: 2.6
TargetRailsVersion: 5.2



Expand Down
7 changes: 3 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end

gem 'rails', '~> 5.1.1'
gem 'rails', '~> 5.2.3'
gem 'rails-i18n', '~> 5.0'
gem 'turbolinks', '~> 5'

Expand Down Expand Up @@ -37,7 +37,6 @@ gem 'will_paginate'
gem 'paginate-responder', '~> 2.0'
gem 'decorate-responder', '~> 2.0'
gem 'api-responder'
gem 'baby_squeel'

gem 'pg', '~> 1.0' # missing compability with rails

Expand All @@ -64,8 +63,8 @@ group :development do
gem 'spring'
gem 'spring-commands-rspec'

gem 'rubocop', '~> 0.58.1'
gem 'rubocop-rspec', '~> 1.29'
gem 'rubocop', '~> 0.58.1', require: false
gem 'rubocop-rspec', '~> 1.29', require: false
end

group :development, :test do
Expand Down
93 changes: 46 additions & 47 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,47 @@ GEM
accept_values_for (0.9.0)
activemodel (>= 5.0, < 6.1)
rspec (>= 3.0, < 4.0)
actioncable (5.1.7)
actionpack (= 5.1.7)
actioncable (5.2.3)
actionpack (= 5.2.3)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
websocket-driver (>= 0.6.1)
actionmailer (5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.1.7)
actionview (= 5.1.7)
activesupport (= 5.1.7)
actionpack (5.2.3)
actionview (= 5.2.3)
activesupport (= 5.2.3)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.7)
activesupport (= 5.1.7)
actionview (5.2.3)
activesupport (= 5.2.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.7)
activesupport (= 5.1.7)
activejob (5.2.3)
activesupport (= 5.2.3)
globalid (>= 0.3.6)
activemodel (5.1.7)
activesupport (= 5.1.7)
activemodel (5.2.3)
activesupport (= 5.2.3)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
activerecord (5.1.7)
activemodel (= 5.1.7)
activesupport (= 5.1.7)
arel (~> 8.0)
activesupport (5.1.7)
activerecord (5.2.3)
activemodel (= 5.2.3)
activesupport (= 5.2.3)
arel (>= 9.0)
activestorage (5.2.3)
actionpack (= 5.2.3)
activerecord (= 5.2.3)
marcel (~> 0.3.1)
activesupport (5.2.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
Expand All @@ -49,14 +53,10 @@ GEM
public_suffix (>= 2.0.2, < 5.0)
api-responder (1.0.1)
activesupport
arel (8.0.0)
arel (9.0.0)
ast (2.4.0)
autoprefixer-rails (9.6.1.1)
execjs
baby_squeel (1.3.1)
activerecord (>= 4.2.0)
join_dependency (~> 0.1.2)
polyamorous (~> 1.3)
bcrypt (3.1.13)
bourbon (6.0.0)
thor (~> 0.19)
Expand Down Expand Up @@ -143,8 +143,6 @@ GEM
i18n (1.6.0)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.3)
join_dependency (0.1.4)
activerecord (>= 4.2.0)
jquery-rails (4.3.5)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
Expand All @@ -164,7 +162,10 @@ GEM
lumberjack (1.0.13)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mimemagic (0.3.3)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
mini_racer (0.2.6)
Expand Down Expand Up @@ -220,8 +221,6 @@ GEM
capybara (>= 2.1, < 4)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
polyamorous (1.3.3)
activerecord (>= 3.0)
powerpack (0.1.2)
pry (0.12.2)
coderay (~> 1.1.0)
Expand All @@ -238,17 +237,18 @@ GEM
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.1.7)
actioncable (= 5.1.7)
actionmailer (= 5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
activemodel (= 5.1.7)
activerecord (= 5.1.7)
activesupport (= 5.1.7)
rails (5.2.3)
actioncable (= 5.2.3)
actionmailer (= 5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
activemodel (= 5.2.3)
activerecord (= 5.2.3)
activestorage (= 5.2.3)
activesupport (= 5.2.3)
bundler (>= 1.3.0)
railties (= 5.1.7)
railties (= 5.2.3)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x)
Expand All @@ -265,12 +265,12 @@ GEM
rails-timeago (2.17.1)
actionpack (>= 3.1)
activesupport (>= 3.1)
railties (5.1.7)
actionpack (= 5.1.7)
activesupport (= 5.1.7)
railties (5.2.3)
actionpack (= 5.2.3)
activesupport (= 5.2.3)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
rake (12.3.3)
rb-fsevent (0.10.3)
Expand Down Expand Up @@ -375,7 +375,7 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.6.5)
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
whenever (1.0.0)
Expand All @@ -391,7 +391,6 @@ DEPENDENCIES
accept_values_for (>= 0.7.4)
api-responder
autoprefixer-rails (~> 9.6)
baby_squeel
bcrypt
bourbon (~> 6.0)
brakeman
Expand Down Expand Up @@ -427,7 +426,7 @@ DEPENDENCIES
pry-byebug
puma (~> 4.1)
rack-cors
rails (~> 5.1.1)
rails (~> 5.2.3)
rails-controller-testing
rails-i18n (~> 5.0)
rails-timeago
Expand Down
19 changes: 16 additions & 3 deletions app/models/feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@ class Feed < ApplicationRecord
belongs_to :source
has_many :fetches, class_name: 'FeedFetch'
has_many :messages, as: :messageable

scope :fetch_needed, -> {
where.has { next_fetch_at < Time.zone.now }.order(:next_fetch_at)
where('next_fetch_at < ?', Time.zone.now).order(:next_fetch_at)
}

scope :archived, lambda {
joins(source: :canteen).where(sources: {canteens: {state: 'archived' }})
}

scope :inactive, lambda {
where('(schedule IS NULL OR id IN (?))', Feed.archived.select(:id))
}

scope :active, lambda {
where('(schedule IS NOT NULL AND id NOT IN (?))', Feed.archived.select(:id))
}

def canteen
Expand All @@ -14,8 +27,8 @@ def canteen

def feed_timespans
{
lastday: fetches.where.has { executed_at > 1.day.ago },
lastweek: fetches.where.has { executed_at > 1.week.ago },
lastday: fetches.where('executed_at > ?', 1.day.ago),
lastweek: fetches.where('executed_at > ?', 1.week.ago),
total: fetches
}
end
Expand Down
2 changes: 1 addition & 1 deletion bin/bundle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle')
4 changes: 1 addition & 3 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
APP_ROOT = File.expand_path('..', __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
Expand All @@ -21,7 +20,6 @@ chdir APP_ROOT do
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')


# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
Expand Down
6 changes: 4 additions & 2 deletions bin/update
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
APP_ROOT = File.expand_path('..', __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
Expand All @@ -18,6 +17,9 @@ chdir APP_ROOT do
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

# Install JavaScript dependencies if using Yarn
# system('bin/yarn')

puts "\n== Updating database =="
system! 'bin/rails db:migrate'

Expand Down
15 changes: 12 additions & 3 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
require File.expand_path('../boot', __FILE__)
require_relative 'boot'

require 'rails'

# Pick the frameworks you want:
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'sprockets/railtie'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
#
# Assets should be precompiled for production (so we don't need the gems loaded then)
Bundler.require(*Rails.groups(assets: %w(development test)))

Expand Down Expand Up @@ -40,15 +45,19 @@ class Application < Rails::Application
config.session_store :cookie_store, key: '_openmensa_session'
config.action_dispatch.cookies_serializer = :hybrid

# Asset configuration
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
config.assets.paths << Rails.root.join('node_modules')

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# config.assets.precompile += %w( admin.js admin.css )

# Load ruby platform specific database configuration
def config.database_configuration
files = []
Expand Down
6 changes: 3 additions & 3 deletions config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Load the rails application
require File.expand_path('../application', __FILE__)
# Load the Rails application.
require_relative 'application'

# Initialize the rails application
# Initialize the Rails application.
Rails.application.initialize!
11 changes: 9 additions & 2 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@
config.consider_all_requests_local = true

# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true

config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false

config.cache_store = :null_store
end

# Store uploaded files on the local file system (see config/storage.yml for options)
# config.active_storage.service = :local

# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false

Expand All @@ -37,6 +41,9 @@
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load

# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
Expand Down

0 comments on commit 89dc568

Please sign in to comment.