Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
(Test) does memory usage improve on Ruby 2.6?
Browse files Browse the repository at this point in the history
* Ruby protobuffs was mentioned: puma/puma#1600 - while we aren’t on the same versions as mentioned, it could be worth a try.
  • Loading branch information
tahb committed Feb 28, 2019
1 parent bca93ec commit 6e5f380
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
@@ -1,6 +1,6 @@
inherit_from: .rubocop_todo.yml
AllCops:
TargetRubyVersion: 2.4
TargetRubyVersion: 2.6
Exclude:
- 'db/migrate/**/*'
- 'db/schema.rb'
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
@@ -1 +1 @@
2.4.1
2.6.1
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -9,7 +9,7 @@ COPY package-lock.json ./package-lock.json
RUN npm set progress=false && npm config set depth 0
RUN npm install --only=production

FROM ruby:2.4.1 as release
FROM ruby:2.6.1 as release
MAINTAINER dxw <rails@dxw.com>
RUN apt-get update && apt-get install -qq -y \
build-essential \
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

ruby '2.4.1'
ruby '2.6.1'

git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
Expand Down Expand Up @@ -47,7 +47,7 @@ gem 'xml-sitemap'

gem 'rollbar', '~> 2.18'

gem 'rubocop' # Not in Test group due to: https://github.com/chapmanu/imposter/issues/4
gem 'rubocop', '~> 0.65.0', require: false # Not in Test group due to: https://github.com/chapmanu/imposter/issues/4

gem 'activerecord-session_store'
gem 'public_activity'
Expand Down Expand Up @@ -87,7 +87,7 @@ group :test do
gem 'database_cleaner'
gem 'poltergeist'
gem 'rspec-collection_matchers'
gem 'webmock', '~> 3.4'
gem 'webmock', '~> 3.5'
gem 'shoulda-matchers'
gem 'rack_session_access'
end
Expand Down
28 changes: 15 additions & 13 deletions Gemfile.lock
Expand Up @@ -170,7 +170,7 @@ GEM
haml (>= 4.0.6, < 6.0)
html2haml (>= 1.0.1)
railties (>= 4.0.1)
hashdiff (0.3.7)
hashdiff (0.3.8)
hashie (3.5.7)
high_voltage (3.1.0)
html2haml (2.2.0)
Expand All @@ -185,7 +185,7 @@ GEM
i18n (1.5.3)
concurrent-ruby (~> 1.0)
ipaddr (1.2.2)
jaro_winkler (1.5.1)
jaro_winkler (1.5.2)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
Expand Down Expand Up @@ -266,8 +266,8 @@ GEM
validate_url
webfinger (>= 1.0.1)
os (1.0.0)
parallel (1.12.1)
parser (2.5.1.2)
parallel (1.14.0)
parser (2.6.0.0)
ast (~> 2.4.0)
pg (1.1.4)
poltergeist (1.18.1)
Expand All @@ -278,6 +278,7 @@ GEM
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
psych (3.1.0)
public_activity (1.6.3)
actionpack (>= 3.0.0)
activerecord (>= 3.0)
Expand Down Expand Up @@ -368,19 +369,20 @@ GEM
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rubocop (0.58.2)
rubocop (0.65.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
psych (>= 3.1.0)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
unicode-display_width (~> 1.4.0)
ruby-progressbar (1.10.0)
ruby_dep (1.5.0)
ruby_parser (3.11.0)
sexp_processor (~> 4.9)
safe_yaml (1.0.4)
safe_yaml (1.0.5)
sanitize (5.0.0)
crass (~> 1.0.2)
nokogiri (>= 1.8.0)
Expand Down Expand Up @@ -445,7 +447,7 @@ GEM
uber (0.1.0)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.4.0)
unicode-display_width (1.4.1)
validate_email (0.1.6)
activemodel (>= 3.0)
mail (>= 2.2.5)
Expand All @@ -460,7 +462,7 @@ GEM
webfinger (1.1.0)
activesupport
httpclient (>= 2.4)
webmock (3.4.2)
webmock (3.5.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
Expand Down Expand Up @@ -522,7 +524,7 @@ DEPENDENCIES
rollbar (~> 2.18)
rspec-collection_matchers
rspec-rails
rubocop
rubocop (~> 0.65.0)
sanitize (~> 5.0)
sass-rails (~> 5.0)
shoulda-matchers
Expand All @@ -536,11 +538,11 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
webmock (~> 3.4)
webmock (~> 3.5)
xml-sitemap

RUBY VERSION
ruby 2.4.1p111
ruby 2.6.1p33

BUNDLED WITH
1.17.1
1.17.2
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Expand Up @@ -24,6 +24,7 @@ def not_found

def check_staging_auth
return unless authenticate?

authenticate_or_request_with_http_basic('Global') do |name, password|
name == http_user && password == http_pass
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/hiring_staff/base_controller.rb
Expand Up @@ -24,6 +24,7 @@ def current_school

def current_user
return if current_session_id.blank?

@current_user ||= User.find_or_create_by(oid: current_session_id)
end
end
Expand Up @@ -16,6 +16,7 @@ def create
comment: feedback_params[:comment])

return render 'new' unless @feedback.save

audit_feedback(vacancy, @feedback)

redirect_to school_path, notice: I18n.t('messages.feedback.submitted')
Expand Down
1 change: 1 addition & 0 deletions app/controllers/interests_controller.rb
Expand Up @@ -13,6 +13,7 @@ def new

def vacancy_id
return params.require(:vacancy_id) if params.key?('vacancy_id')

params.require(:job_id)
end
end
1 change: 1 addition & 0 deletions app/controllers/pages_controller.rb
Expand Up @@ -7,6 +7,7 @@ def invalid_page

def set_headers
return super if page_path.include?('user-not-authorised')

response.set_header('X-Robots-Tag', 'index, nofollow')
end
end
1 change: 1 addition & 0 deletions app/controllers/vacancies_controller.rb
Expand Up @@ -26,6 +26,7 @@ def index
def show
vacancy = Vacancy.listed.friendly.find(id)
return redirect_to(job_path(vacancy), status: :moved_permanently) if old_vacancy_path?(vacancy)

@vacancy = VacancyPresenter.new(vacancy)

expires_in 5.minutes, public: true
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/date_helper.rb
Expand Up @@ -3,8 +3,10 @@ class FormatDateError < RuntimeError; end

def format_date(date, format = :default)
return 'No date given' if date.nil?

date_formats = Date::DATE_FORMATS.keys.join(' ')
raise FormatDateError, date_format_error_message(format, date_formats) unless Date::DATE_FORMATS.include?(format)

date.to_s(format).lstrip
end

Expand Down
1 change: 1 addition & 0 deletions app/jobs/performance_platform_feedback_queue_job.rb
Expand Up @@ -5,6 +5,7 @@ class PerformancePlatformFeedbackQueueJob < ApplicationJob
def perform(time_to_s)
date = Time.zone.parse(time_to_s)
return if TransactionAuditor::Logger.new('performance_platform:submit_user_satisfaction', date).performed?

data = { 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0 }.merge!(Feedback.published_on(date).group(:rating).count)
PerformancePlatform::UserSatisfaction.new(PP_USER_SATISFACTION_TOKEN)
.submit(data, date.utc.iso8601)
Expand Down
1 change: 1 addition & 0 deletions app/jobs/performance_platform_transactions_queue_job.rb
Expand Up @@ -6,6 +6,7 @@ def perform(time_to_s)
date = Time.zone.parse(time_to_s)

return if TransactionAuditor::Logger.new('performance_platform:submit_transactions', date).performed?

no_of_transactions = Vacancy.published_on_count(date)
PerformancePlatform::TransactionsByChannel.new(PP_TRANSACTIONS_BY_CHANNEL_TOKEN)
.submit_transactions(no_of_transactions, date.utc.iso8601)
Expand Down
2 changes: 1 addition & 1 deletion app/models/school.rb
Expand Up @@ -2,7 +2,7 @@
class School < ApplicationRecord
include Auditor::Model

belongs_to :school_type, required: true
belongs_to :school_type, optional: false
belongs_to :detailed_school_type, optional: true
belongs_to :region

Expand Down
15 changes: 8 additions & 7 deletions app/models/vacancy.rb
Expand Up @@ -78,13 +78,13 @@ class Vacancy < ApplicationRecord
enum status: %i[published draft trashed]
enum working_pattern: %i[full_time part_time]

belongs_to :school, required: true
belongs_to :subject, required: false
belongs_to :first_supporting_subject, class_name: 'Subject', required: false
belongs_to :second_supporting_subject, class_name: 'Subject', required: false
belongs_to :min_pay_scale, class_name: 'PayScale', required: false
belongs_to :max_pay_scale, class_name: 'PayScale', required: false
belongs_to :leadership, required: false
belongs_to :school, optional: false
belongs_to :subject, optional: true
belongs_to :first_supporting_subject, class_name: 'Subject', optional: true
belongs_to :second_supporting_subject, class_name: 'Subject', optional: true
belongs_to :min_pay_scale, class_name: 'PayScale', optional: true
belongs_to :max_pay_scale, class_name: 'PayScale', optional: true
belongs_to :leadership, optional: true

has_one :feedback

Expand Down Expand Up @@ -115,6 +115,7 @@ def location

def coordinates
return if school_geolocation.nil?

{
lat: school_geolocation.x.to_f,
lon: school_geolocation.y.to_f
Expand Down
2 changes: 2 additions & 0 deletions app/presenters/vacancies_presenter.rb
Expand Up @@ -23,9 +23,11 @@ def each(&block)
def total_count_message
if total_count == 1
return I18n.t('jobs.job_count_without_search', count: total_count) unless @searched

I18n.t('jobs.job_count', count: total_count)
else
return I18n.t('jobs.job_count_plural_without_search', count: total_count) unless @searched

I18n.t('jobs.job_count_plural', count: total_count)
end
end
Expand Down
3 changes: 3 additions & 0 deletions app/presenters/vacancy_presenter.rb
Expand Up @@ -10,6 +10,7 @@ def share_url

def salary_range(del = 'to')
return number_to_currency(model.minimum_salary) if model.maximum_salary.blank?

"#{number_to_currency(model.minimum_salary)} #{del} "\
"#{number_to_currency(model.maximum_salary)}"\
"#{model.part_time? ? ' per year pro rata' : ' per year'}"
Expand Down Expand Up @@ -64,6 +65,7 @@ def other_subjects
return '' if first_supporting_subject.blank? && second_supporting_subject.blank?
return first_supporting_subject if only_first_supporting_subject_present?
return second_supporting_subject if only_second_supporting_subject_present?

supporting_subjects
end
end
Expand All @@ -85,6 +87,7 @@ def pay_scale_range
return '' if model.min_pay_scale.blank? && model.max_pay_scale.blank?
return "from #{model.min_pay_scale.label}" if only_min_pay_scale_present?
return "up to #{model.max_pay_scale.label}" if only_max_pay_scale_present?

pay_scale_range_label
end
end
Expand Down
1 change: 1 addition & 0 deletions app/services/teacher_vacancy_authorisation.rb
Expand Up @@ -26,6 +26,7 @@ def all_permissions
def school_urn
return nil unless user_permissions.any?
return user_permissions_for_school.first['school_urn'] if @school_urn.present?

user_permissions.first['school_urn']
end

Expand Down
7 changes: 7 additions & 0 deletions app/services/vacancy_search_builder.rb
Expand Up @@ -14,6 +14,7 @@ def initialize(filters:, sort:, expired: false, status: :published)
@status = status

return if filters.location.blank?

@geocoded_location = Geocoding.new(filters.location).coordinates
@radius = filters.radius.to_i.positive? ? filters.radius.to_i : MIN_ALLOWED_RADIUS
end
Expand Down Expand Up @@ -73,6 +74,7 @@ def location_geo_distance

def expired_query
return if @expired

{
range: {
'expires_on': {
Expand All @@ -84,6 +86,7 @@ def expired_query

def published_on_query
return if @published_on

{
range: {
'publish_on': {
Expand All @@ -95,6 +98,7 @@ def published_on_query

def status_query
return if @status.blank?

{
bool: {
filter: {
Expand All @@ -108,6 +112,7 @@ def status_query

def working_pattern_query
return if @working_pattern.blank?

{
bool: {
filter: {
Expand All @@ -121,6 +126,7 @@ def working_pattern_query

def newly_qualified_teacher_query
return if @newly_qualified_teacher.blank?

{
bool: {
filter: {
Expand All @@ -134,6 +140,7 @@ def newly_qualified_teacher_query

def phase_query
return if @phase.blank?

{
bool: {
filter: {
Expand Down
1 change: 1 addition & 0 deletions app/validators/date_format_validator.rb
Expand Up @@ -3,6 +3,7 @@ def validate(record)
options[:fields].each do |field|
date = record.send(field)
next if date.blank?

match = date.strftime('%Y-%m-%d').match(/^(?<y>\d*)\-/)

record.errors.add(field, I18n.t('errors.messages.year_invalid')) if match[:y].length > 4
Expand Down
2 changes: 1 addition & 1 deletion app/validators/salary_validator.rb
Expand Up @@ -4,7 +4,7 @@ class SalaryValidator < ActiveModel::EachValidator

rescue_from ArgumentError, with: :invalid_format_message

SALARY_FORMAT = /^\d+\.{0,1}\d{2}{0,1}$/
SALARY_FORMAT = /^\d+\.{0,1}\d{2}{0,1}$/.freeze
MIN_SALARY_ALLOWED = 0
MAX_SALARY_ALLOWED = 200000

Expand Down

0 comments on commit 6e5f380

Please sign in to comment.