mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 10:19:52 +01:00
Remove relationship counters in users
table
This commit is contained in:
parent
ce951453a2
commit
d20e07ee19
6 changed files with 11 additions and 15 deletions
2
Rakefile
2
Rakefile
|
@ -69,8 +69,6 @@ namespace :justask do
|
|||
asked = Question.where(user: user).where(author_is_anonymous: false).count
|
||||
commented = Comment.where(user: user).count
|
||||
smiled = Smile.where(user: user).count
|
||||
user.friend_count = user.friends.count
|
||||
user.follower_count = user.followers.count
|
||||
user.answered_count = answered
|
||||
user.asked_count = asked
|
||||
user.commented_count = commented
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
class Relationships::Follow < Relationship
|
||||
after_create do
|
||||
Notification.notify target, self
|
||||
# increment counts
|
||||
source.increment! :friend_count
|
||||
target.increment! :follower_count
|
||||
end
|
||||
|
||||
before_destroy do
|
||||
Notification.denotify target, self
|
||||
# decrement counts
|
||||
source.decrement! :friend_count
|
||||
target.decrement! :follower_count
|
||||
end
|
||||
|
||||
def notification_type(*_args)
|
||||
|
|
|
@ -76,10 +76,10 @@
|
|||
%p.text-muted= current_user.asked_count
|
||||
|
||||
%p.font-weight-bold.mb-0 Following
|
||||
%p.text-muted= current_user.friend_count
|
||||
%p.text-muted= current_user.followings.count
|
||||
|
||||
%p.font-weight-bold.mb-0 Followers
|
||||
%p.text-muted= current_user.follower_count
|
||||
%p.text-muted= current_user.followers.count
|
||||
|
||||
%p.font-weight-bold.mb-0 Smiles
|
||||
%p.text-muted= current_user.smiled_count + current_user.comment_smiled_count
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class RemoveRelationshipCountersFromUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
remove_column :users, :follower_count
|
||||
remove_column :users, :friend_count
|
||||
end
|
||||
end
|
|
@ -275,8 +275,6 @@ ActiveRecord::Schema.define(version: 2022_01_05_171216) do
|
|||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "screen_name"
|
||||
t.integer "friend_count", default: 0, null: false
|
||||
t.integer "follower_count", default: 0, null: false
|
||||
t.integer "asked_count", default: 0, null: false
|
||||
t.integer "answered_count", default: 0, null: false
|
||||
t.integer "commented_count", default: 0, null: false
|
||||
|
|
|
@ -36,7 +36,7 @@ class Exporter
|
|||
def collect_user_info
|
||||
%i(answered_count asked_count ban_reason banned_until comment_smiled_count commented_count
|
||||
confirmation_sent_at confirmed_at created_at profile_header profile_header_h profile_header_w profile_header_x profile_header_y
|
||||
profile_picture_w profile_picture_h profile_picture_x profile_picture_y current_sign_in_at current_sign_in_ip follower_count friend_count
|
||||
profile_picture_w profile_picture_h profile_picture_x profile_picture_y current_sign_in_at current_sign_in_ip
|
||||
id last_sign_in_at last_sign_in_ip locale permanently_banned
|
||||
privacy_allow_anonymous_questions privacy_allow_public_timeline privacy_allow_stranger_answers
|
||||
privacy_show_in_search profile_header_file_name profile_picture_file_name
|
||||
|
@ -232,8 +232,8 @@ class Exporter
|
|||
|
||||
def user_stub(user)
|
||||
uobj = {}
|
||||
%i(answered_count asked_count comment_smiled_count commented_count created_at follower_count
|
||||
friend_count id permanently_banned screen_name smiled_count).each do |f|
|
||||
%i(answered_count asked_count comment_smiled_count commented_count created_at
|
||||
id permanently_banned screen_name smiled_count).each do |f|
|
||||
uobj[f] = user.send f
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue