move uploader upload count increment from upload to post

This commit is contained in:
Albert Yi
2018-06-20 10:43:48 -07:00
parent 3f6e069eed
commit 62218fdb51
3 changed files with 2 additions and 6 deletions

View File

@@ -304,11 +304,7 @@ class UploadService
end
def start!(uploader_id)
if source.present?
if !Utils.is_downloadable?(source)
return
end
if Utils.is_downloadable?(source)
CurrentUser.as_system do
if Post.tag_match("source:#{source}").exists?
return

View File

@@ -40,6 +40,7 @@ class Post < ApplicationRecord
after_commit :remove_iqdb_async, :on => :destroy
after_commit :update_iqdb_async, :on => :create
after_commit :notify_pubsub
after_create {|rec| rec.uploader.increment!(:post_upload_count)}
belongs_to :updater, :class_name => "User", optional: true # this is handled in versions
belongs_to :approver, class_name: "User", optional: true

View File

@@ -63,7 +63,6 @@ class Upload < ApplicationRecord
validates :file_ext, format: { with: /jpg|gif|png|swf|webm|mp4|zip/ }, allow_nil: true
validates_with Validator
serialize :context, JSON
after_create {|rec| rec.uploader.increment!(:post_upload_count)}
def initialize_attributes
self.uploader_id = CurrentUser.user.id