Skip to content

Commit bad71b3

Browse files
committed
Rubocop auto-correct
1 parent 8b33b83 commit bad71b3

30 files changed

+161
-156
lines changed

app/background_tasks/kafka_batch_update_points_task.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def update_user_progress(task)
6161
points_per_user = AwardedPoint.count_per_user_in_course_with_sheet(course, parts, user)
6262
available_points = AvailablePoint.course_sheet_points(course, parts)
6363
unless points_per_user[user.username]
64-
Rails.logger.info("No points found. Skipping")
64+
Rails.logger.info('No points found. Skipping')
6565
return true
6666
end
6767
progress = points_per_user[user.username].map do |group_name, awarded_points|

app/background_tasks/sandbox_status_fetcher_task.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def run
2222
data[:fetching_time] = fetching_time.real.round(2)
2323
data
2424
end
25-
Rails.cache.write("sandbox-status-cache", data.to_json, expires_in: 1.minute)
25+
Rails.cache.write('sandbox-status-cache', data.to_json, expires_in: 1.minute)
2626
end
2727

2828
def wait_delay

app/background_tasks/stats_fetcher_task.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class StatsFetcherTask
24
def initialize
35
end
@@ -14,7 +16,7 @@ def run
1416
submissions_count_yesterday: Submission.where(created_at: Time.current.yesterday.all_day).count,
1517
submissions_count_week: Submission.where(created_at: Time.current.all_week).count,
1618
}
17-
Rails.cache.write("stats-cache", data.to_json, expires_in: 1.minute)
19+
Rails.cache.write('stats-cache', data.to_json, expires_in: 1.minute)
1820
end
1921

2022
def wait_delay

app/background_tasks/uncomputed_unlock_computor_task.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def initialize
77
end
88

99
def run
10-
UncomputedUnlock.order("id ASC").limit(1).each do |uncomputed_unlock|
10+
UncomputedUnlock.order('id ASC').limit(1).each do |uncomputed_unlock|
1111
course = uncomputed_unlock.course
1212
user = uncomputed_unlock.user
1313
Rails.logger.info "Calculating unlocks for user #{user.id} and course #{course.name}. Queue length: #{UncomputedUnlock.count}."

app/controllers/api/v8/base_controller.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ def errors_json(messages)
5353
def respond_not_found(msg = 'Not Found')
5454
respond_with_error(msg, 404)
5555
end
56-
56+
5757
def respond_forbidden(msg = 'Forbidden')
5858
respond_with_error(msg, 403)
5959
end
60-
60+
6161
def respond_unauthorized(msg = 'Authentication required')
6262
respond_with_error(msg, 401)
6363
end
64-
64+
6565
def respond_with_error(msg, code = 500, exception = nil, extra_json_keys = {})
6666
respond_to do |format|
6767
format.html do
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,68 @@
11
# frozen_string_literal: true
22

33
module Api
4-
module V8
5-
module Core
6-
module Exercises
7-
class DetailsController < Api::V8::BaseController
8-
include Swagger::Blocks
4+
module V8
5+
module Core
6+
module Exercises
7+
class DetailsController < Api::V8::BaseController
8+
include Swagger::Blocks
99

10-
swagger_path '/api/v8/core/exercises/details' do
11-
operation :get do
12-
key :description, 'Fetch multiple exercise details as query parameters.'
13-
key :operationId, 'getExerciseDetailsWithIds'
14-
key :produces, ['application/json']
15-
key :tags, ['core']
16-
parameter do
17-
key :in, 'query'
18-
key :name, 'ids'
19-
schema do
20-
key :type, :array
21-
items do
22-
key :type, :integer
23-
end
24-
end
10+
swagger_path '/api/v8/core/exercises/details' do
11+
operation :get do
12+
key :description, 'Fetch multiple exercise details as query parameters.'
13+
key :operationId, 'getExerciseDetailsWithIds'
14+
key :produces, ['application/json']
15+
key :tags, ['core']
16+
parameter do
17+
key :in, 'query'
18+
key :name, 'ids'
19+
schema do
2520
key :type, :array
26-
key :description, 'Exercise Ids'
21+
items do
22+
key :type, :integer
23+
end
2724
end
28-
response 200 do
29-
key :description, 'Exercises in json'
30-
schema do
31-
key :title, :exercises
32-
key :required, [:exercises]
33-
property :exercises do
34-
key :type, :array
35-
items do
36-
key :'$ref', :CoreExerciseQueryDetails
37-
end
25+
key :type, :array
26+
key :description, 'Exercise Ids'
27+
end
28+
response 200 do
29+
key :description, 'Exercises in json'
30+
schema do
31+
key :title, :exercises
32+
key :required, [:exercises]
33+
property :exercises do
34+
key :type, :array
35+
items do
36+
key :'$ref', :CoreExerciseQueryDetails
3837
end
3938
end
4039
end
41-
response 403, '$ref': '#/responses/error'
42-
response 404, '$ref': '#/responses/error'
4340
end
41+
response 403, '$ref': '#/responses/error'
42+
response 404, '$ref': '#/responses/error'
4443
end
44+
end
4545

46-
skip_authorization_check
46+
skip_authorization_check
4747

48-
def show
49-
exercise_ids = params[:ids]
50-
return respond_not_found('Query param ids is empty. Example: ?ids=1,2,3') if !exercise_ids.present? || exercise_ids.empty?
48+
def show
49+
exercise_ids = params[:ids]
50+
return respond_not_found('Query param ids is empty. Example: ?ids=1,2,3') if !exercise_ids.present? || exercise_ids.empty?
5151

52-
exercises = Exercise.where(id: exercise_ids.split(",")).includes(:course)
53-
authorize! :read, exercises
54-
data = exercises.map do |exercise|
55-
{
56-
id: exercise.id,
57-
checksum: exercise.checksum,
58-
course_name: exercise.course.name,
59-
exercise_name: exercise.name,
60-
}
61-
end
62-
present exercises: data
52+
exercises = Exercise.where(id: exercise_ids.split(',')).includes(:course)
53+
authorize! :read, exercises
54+
data = exercises.map do |exercise|
55+
{
56+
id: exercise.id,
57+
checksum: exercise.checksum,
58+
course_name: exercise.course.name,
59+
exercise_name: exercise.name,
60+
}
6361
end
62+
present exercises: data
6463
end
6564
end
6665
end
6766
end
6867
end
69-
68+
end

app/controllers/api/v8/user_app_datum_controller.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
module Api
44
module V8
55
class UserAppDatumController < Api::V8::BaseController
6-
76
skip_authorization_check
87
def index
98
only_admins!
109

1110
if params[:after]
1211
timestamp = Time.zone.parse(params[:after])
13-
data = UserAppDatum.where("created_at >= ? OR updated_at >= ?", timestamp, timestamp)
12+
data = UserAppDatum.where('created_at >= ? OR updated_at >= ?', timestamp, timestamp)
1413
return render json: data
1514
end
1615

app/controllers/api/v8/user_field_value_controller.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
module Api
44
module V8
55
class UserFieldValueController < Api::V8::BaseController
6-
76
skip_authorization_check
87
def index
98
only_admins!
109

1110
if params[:after]
1211
timestamp = Time.zone.parse(params[:after])
13-
data = UserFieldValue.order(:updated_at).where("created_at >= ? OR updated_at >= ?", timestamp, timestamp)
12+
data = UserFieldValue.order(:updated_at).where('created_at >= ? OR updated_at >= ?', timestamp, timestamp)
1413
return render json: data
1514
end
1615

app/controllers/api/v8/users/basic_info_by_emails_controller.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ def create
8181
d[:extra_fields] = extra_fields.map { |o| [o.field_name, o.value] }.to_h
8282
end
8383
if params[:user_fields]
84-
user_fields = u.user_field_values.map {|o| [o.field_name, o.value]}.to_h
84+
user_fields = u.user_field_values.map { |o| [o.field_name, o.value] }.to_h
8585
d[:user_fields] = user_fields
86-
d[:student_number] = user_fields["organizational_id"]
87-
d[:first_name] = user_fields["first_name"]
88-
d[:last_name] = user_fields["last_name"]
86+
d[:student_number] = user_fields['organizational_id']
87+
d[:first_name] = user_fields['first_name']
88+
d[:last_name] = user_fields['last_name']
8989
end
9090
d
9191
end

app/controllers/api/v8/users/basic_info_by_ids_controller.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ def create
3131
d[:extra_fields] = extra_fields.map { |o| [o.field_name, o.value] }.to_h
3232
end
3333
if params[:user_fields]
34-
user_fields = u.user_field_values.map {|o| [o.field_name, o.value]}.to_h
34+
user_fields = u.user_field_values.map { |o| [o.field_name, o.value] }.to_h
3535
d[:user_fields] = user_fields
36-
d[:student_number] = user_fields["organizational_id"]
37-
d[:first_name] = user_fields["first_name"]
38-
d[:last_name] = user_fields["last_name"]
36+
d[:student_number] = user_fields['organizational_id']
37+
d[:first_name] = user_fields['first_name']
38+
d[:last_name] = user_fields['last_name']
3939
end
4040
d
4141
end

app/controllers/api/v8/users/basic_info_by_usernames_controller.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def create
8383
d[:extra_fields] = extra_fields.map { |o| [o.field_name, o.value] }.to_h
8484
end
8585
if params[:user_fields]
86-
user_fields = u.user_field_values.map {|o| [o.field_name, o.value]}.to_h
86+
user_fields = u.user_field_values.map { |o| [o.field_name, o.value] }.to_h
8787
d[:user_fields] = user_fields
88-
d[:student_number] = user_fields["organizational_id"]
89-
d[:first_name] = user_fields["first_name"]
90-
d[:last_name] = user_fields["last_name"]
88+
d[:student_number] = user_fields['organizational_id']
89+
d[:first_name] = user_fields['first_name']
90+
d[:last_name] = user_fields['last_name']
9191
end
9292
d
9393
end

app/controllers/results_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def create
1212

1313
# The sandbox output may contain broken characters e.g. if the student
1414
# pointed a C char* towards some patch of interesting memory :)
15-
filtered_params = Hash[(params.keys-["result"]).map do |k|
15+
filtered_params = Hash[(params.keys - ['result']).map do |k|
1616
[k, view_context.force_utf8_violently(params[k])]
1717
end]
1818

app/controllers/solutions_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def show
1818
if current_user.guest?
1919
raise CanCan::AccessDenied
2020
elsif !current_user.email_verified?
21-
return respond_forbidden("Please verify your email address in order to see solutions.")
21+
return respond_forbidden('Please verify your email address in order to see solutions.')
2222
elsif current_user.teacher?(@organization) || current_user.assistant?(@course)
2323
return respond_forbidden("You can't see model solutions until organization is verified by administrator")
2424
else

app/controllers/status_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
class StatusController < ApplicationController
55
def index
66
authorize! :read_instance_state, nil
7-
@stats = Rails.cache.fetch("stats-cache")
7+
@stats = Rails.cache.fetch('stats-cache')
88
@stats = JSON.parse(@stats) if @stats
9-
@sandboxes = Rails.cache.fetch("sandbox-status-cache")
9+
@sandboxes = Rails.cache.fetch('sandbox-status-cache')
1010
@sandboxes = JSON.parse(@sandboxes) if @sandboxes
1111
end
1212
end

app/controllers/submissions_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,13 @@ def check_access!
335335
respond_forbidden("You cannot see this paste because you haven't completed this exercise.")
336336
return
337337
else
338-
respond_forbidden("You cannot see this paste because it was created over 2 hours ago.")
338+
respond_forbidden('You cannot see this paste because it was created over 2 hours ago.')
339339
end
340340
return
341341
end
342342
end
343343

344-
respond_forbidden("You cannot see this paste because all tests passed.") unless paste_visible
344+
respond_forbidden('You cannot see this paste because all tests passed.') unless paste_visible
345345
end
346346
end
347347
end

app/controllers/users_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def index
1616

1717
def new
1818
authorize! :create, User
19-
alternative_location = SiteSetting.all_settings["signup_location"]
19+
alternative_location = SiteSetting.all_settings['signup_location']
2020
return redirect_to alternative_location if alternative_location
2121
add_breadcrumb 'Sign up', new_user_path
2222

app/mailers/user_mailer.rb

+23-23
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ def email_confirmation(user, origin = nil, language = nil)
88
@user = user
99
token = user.verification_tokens.email.create!
1010
@url = base_url + confirm_email_path(@user.id, token.token, language: language)
11-
subject = 'Confirm your mooc.fi account email address' if language == "en" || language == "en-lu"
12-
subject = 'Varmista mooc.fi tunnuksesi sähköpostiosoite' if language == "fi"
13-
subject = 'Bekräfta e-postadressen till ditt mooc.fi-konto' if language == "se"
14-
subject = 'Bestätige deine E-Mail-Adresse, um mit dem Kurs zu beginnen' if language == "de" || language == "de-at"
15-
subject = 'Palun kinnita oma e-posti aadress' if language == "ee"
16-
subject = 'Bekreft email adressen din' if language == "no"
17-
subject = 'Apstipriniet savu e-pasta adresi, lai sāktu darbu ar AI' if language == "lv"
18-
subject = 'Confirmez votre adresse électronique pour commencer le cours «Elements of AI».' if language == "fr" || language == "fr-be"
19-
subject = 'Hagyd jóvá az email-címed az Elements of AI/Az MI alapjai -kurzus megkezdéséhez' if language == "hu"
20-
subject = 'Potvrdenie e-mailovej adresy pred začiatkom kurzu Elements of AI' if language == "sk"
21-
subject = 'Confirmați adresa dumneavoastră de e-mail pentru a începe cursul „Elements of AI”.' if language == "ro"
22-
subject = 'Ikkonferma l-indirizz elettroniku tiegħek għall-kors Elements of AI' if language == "mt"
23-
subject = 'Aby rozpocząć kurs „Elements of AI” potwierdź Twój adres e-mail.' if language == "pl"
24-
subject = 'Confirme o seu endereço eletrónico para iniciar o curso «Elements of AI»' if language == "pt"
25-
subject = 'Confirma tu dirección de correo electrónico para empezar a trabajar con Elements of AI' if language == "es"
26-
subject = 'Deimhnigh do sheoladh ríomhphoist chun tús a chur leis an gcúrsa Elements of AI' if language == "ga"
27-
subject = 'Bevestig je e-mailadres om te beginnen aan Elements of AI' if language == "nl" || language == "nl-be"
28-
subject = 'Da biste započeli s tečajem Elements of AI, potvrdite svoju e-adresu.' if language == "hr"
29-
subject = 'Potrdite svoj e-naslov za začetek tečaja Elements of AI.' if language == "sl"
30-
subject = 'Jei norite pradėti kursą „Elements of AI“, patvirtinkite savo e. pašto adresą.' if language == "lt"
31-
subject = 'Επιβεβαιώστε την ηλεκτρονική σας διεύθυνση για να ξεκινήσετε τον κύκλο μαθημάτων «Elements of AI».' if language == "el"
32-
subject = 'Потвърдете своя имейл, за да започнете курса „Elements of AI“.' if language == "bg"
33-
subject = 'Conferma il tuo indirizzo e-mail per cominciare il corso Elements of AI' if language == "it"
11+
subject = 'Confirm your mooc.fi account email address' if language == 'en' || language == 'en-lu'
12+
subject = 'Varmista mooc.fi tunnuksesi sähköpostiosoite' if language == 'fi'
13+
subject = 'Bekräfta e-postadressen till ditt mooc.fi-konto' if language == 'se'
14+
subject = 'Bestätige deine E-Mail-Adresse, um mit dem Kurs zu beginnen' if language == 'de' || language == 'de-at'
15+
subject = 'Palun kinnita oma e-posti aadress' if language == 'ee'
16+
subject = 'Bekreft email adressen din' if language == 'no'
17+
subject = 'Apstipriniet savu e-pasta adresi, lai sāktu darbu ar AI' if language == 'lv'
18+
subject = 'Confirmez votre adresse électronique pour commencer le cours «Elements of AI».' if language == 'fr' || language == 'fr-be'
19+
subject = 'Hagyd jóvá az email-címed az Elements of AI/Az MI alapjai -kurzus megkezdéséhez' if language == 'hu'
20+
subject = 'Potvrdenie e-mailovej adresy pred začiatkom kurzu Elements of AI' if language == 'sk'
21+
subject = 'Confirmați adresa dumneavoastră de e-mail pentru a începe cursul „Elements of AI”.' if language == 'ro'
22+
subject = 'Ikkonferma l-indirizz elettroniku tiegħek għall-kors Elements of AI' if language == 'mt'
23+
subject = 'Aby rozpocząć kurs „Elements of AI” potwierdź Twój adres e-mail.' if language == 'pl'
24+
subject = 'Confirme o seu endereço eletrónico para iniciar o curso «Elements of AI»' if language == 'pt'
25+
subject = 'Confirma tu dirección de correo electrónico para empezar a trabajar con Elements of AI' if language == 'es'
26+
subject = 'Deimhnigh do sheoladh ríomhphoist chun tús a chur leis an gcúrsa Elements of AI' if language == 'ga'
27+
subject = 'Bevestig je e-mailadres om te beginnen aan Elements of AI' if language == 'nl' || language == 'nl-be'
28+
subject = 'Da biste započeli s tečajem Elements of AI, potvrdite svoju e-adresu.' if language == 'hr'
29+
subject = 'Potrdite svoj e-naslov za začetek tečaja Elements of AI.' if language == 'sl'
30+
subject = 'Jei norite pradėti kursą „Elements of AI“, patvirtinkite savo e. pašto adresą.' if language == 'lt'
31+
subject = 'Επιβεβαιώστε την ηλεκτρονική σας διεύθυνση για να ξεκινήσετε τον κύκλο μαθημάτων «Elements of AI».' if language == 'el'
32+
subject = 'Потвърдете своя имейл, за да започнете курса „Elements of AI“.' if language == 'bg'
33+
subject = 'Conferma il tuo indirizzo e-mail per cominciare il corso Elements of AI' if language == 'it'
3434
subject = "#{origin}: #{subject}" if origin
3535
if origin
3636
origin_name = origin.downcase.tr(' ', '_').gsub(/[\.\/]/, '')
+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class KafkaBatchUpdatePoints < ActiveRecord::Base
24
belongs_to :course
35
end

app/models/solution.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def path
1414
@exercise.solution_path
1515
end
1616

17-
def visible_to?(user, ignore_email_verification=false)
17+
def visible_to?(user, ignore_email_verification = false)
1818
if user.administrator?
1919
true
2020
elsif !ignore_email_verification && !user.email_verified?

app/models/unlock.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def self.refresh_unlocks(course, user)
2525
unlocks = course.unlocks.where(user_id: user.id)
2626
by_exercise_name = Hash[unlocks.map { |u| [u.exercise_name, u] }]
2727
fast_refresh_unlocks_impl(course, user, by_exercise_name)
28-
UncomputedUnlock.where(course_id: course.id, user_id: user.id).where("created_at < ?", time).delete_all
28+
UncomputedUnlock.where(course_id: course.id, user_id: user.id).where('created_at < ?', time).delete_all
2929
end
3030
end
3131

config.ru

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
require ::File.expand_path('../config/environment', __FILE__)
66
run TmcServer::Application
77

8-
require "rack/attack"
8+
require 'rack/attack'
99
use Rack::Attack

0 commit comments

Comments
 (0)