implementation of import wip

This commit is contained in:
Karol
2019-08-20 18:37:17 +02:00
parent 818064267c
commit 017644c4a5
15 changed files with 212 additions and 52 deletions

View File

@@ -1,13 +0,0 @@
class CodeHarborLink < ApplicationRecord
validates :oauth2token, presence: true
validates :user_id, presence: true
belongs_to :internal_user, foreign_key: :user_id
alias_method :user, :internal_user
alias_method :user=, :internal_user=
def to_s
oauth2token
end
end

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
class CodeharborLink < ApplicationRecord
validates :oauth2token, presence: true
validates :user_id, presence: true
belongs_to :user, foreign_key: :user_id, class_name: 'InternalUser'
def to_s
oauth2token
end
end

View File

@@ -31,7 +31,7 @@ class Exercise < ApplicationRecord
validate :valid_main_file?
validates :description, presence: true
validates :execution_environment_id, presence: true
# validates :execution_environment_id, presence: true # TODO make this conditional - but based on what?
validates :public, boolean_presence: true
validates :title, presence: true
validates :token, presence: true, uniqueness: true
@@ -49,7 +49,7 @@ class Exercise < ApplicationRecord
0
end
end
def finishers_percentage
if users.distinct.count != 0
(100.0 / users.distinct.count * finishers.count).round(2)