models: refactor class methods into scopes.

This commit is contained in:
evazion
2020-02-17 02:10:08 -06:00
parent 9a8aa1990d
commit 83a0cb0a71
12 changed files with 45 additions and 126 deletions

View File

@@ -68,7 +68,9 @@ class Upload < ApplicationRecord
after_destroy_commit :delete_files
scope :pending, -> { where(status: "pending") }
scope :preprocessed, -> { where(status: "preprocessed") }
scope :uploaded_by, ->(user_id) { where(uploader_id: user_id) }
def initialize_attributes
self.uploader_id = CurrentUser.id
@@ -180,14 +182,6 @@ class Upload < ApplicationRecord
end
module SearchMethods
def uploaded_by(user_id)
where("uploader_id = ?", user_id)
end
def pending
where(:status => "pending")
end
def search(params)
q = super