separate table for fa post favs
This commit is contained in:
@@ -480,7 +480,7 @@ describe Domain::Fa::Job::FavsJob do
|
||||
|
||||
it "works with old models" do
|
||||
post = create(:domain_post_fa_post, fa_id: 58_923_196)
|
||||
user.user_post_favs.create!(type: "Domain::UserPostFav", post_id: post.id)
|
||||
user.user_post_favs.create!(post_id: post.id)
|
||||
perform_now({ url_name: "zzreg" })
|
||||
|
||||
sub_58923196 = user.user_post_favs.find { |f| f.post.fa_id == 58_923_196 }
|
||||
@@ -488,7 +488,7 @@ describe Domain::Fa::Job::FavsJob do
|
||||
|
||||
sub_51810098 = user.user_post_favs.find { |f| f.post.fa_id == 51_810_098 }
|
||||
expect(sub_51810098).to be_a(Domain::UserPostFav::FaUserPostFav)
|
||||
expect(sub_51810098.fav_id).to eq(1_724_359_446)
|
||||
expect(sub_51810098.fa_fav_id).to eq(1_724_359_446)
|
||||
expect(sub_51810098.explicit_time).to eq(date_51810098)
|
||||
end
|
||||
|
||||
@@ -504,19 +504,19 @@ describe Domain::Fa::Job::FavsJob do
|
||||
|
||||
# the first record should have a date
|
||||
sub_51810098 = user.user_post_favs.find { |f| f.post.fa_id == 51_810_098 }
|
||||
expect(sub_51810098.fav_id).to eq(1_724_359_446)
|
||||
expect(sub_51810098.fa_fav_id).to eq(1_724_359_446)
|
||||
expect(sub_51810098.explicit_time).to eq(date_51810098)
|
||||
|
||||
# non-first new records should not have a date populated
|
||||
sub_58724276 = user.user_post_favs.find { |f| f.post.fa_id == 58_724_276 }
|
||||
expect(sub_58724276.fav_id).to eq(1_724_341_165)
|
||||
expect(sub_58724276.fa_fav_id).to eq(1_724_341_165)
|
||||
expect(sub_58724276.explicit_time).to be_nil
|
||||
|
||||
# existing record should have its fav_fa_id populated, and date should be unchanged
|
||||
# The existing post we created should now have the fav_id populated
|
||||
post.reload
|
||||
existing_fav = user.user_post_favs.find { |f| f.post.fa_id == 51_810_098 }
|
||||
expect(existing_fav.fav_id).to eq(1_724_359_446)
|
||||
expect(existing_fav.fa_fav_id).to eq(1_724_359_446)
|
||||
expect(existing_fav.explicit_time).to eq(date_51810098)
|
||||
end
|
||||
end
|
||||
@@ -540,14 +540,16 @@ describe Domain::Fa::Job::FavsJob do
|
||||
end.to change { user.reload.user_post_favs.count }.by(41)
|
||||
|
||||
# first fav should have a date
|
||||
fav_319542674 = user.user_post_favs.find { |f| f.fav_id == 319_542_674 }
|
||||
fav_319542674 =
|
||||
user.user_post_favs.find { |f| f.fa_fav_id == 319_542_674 }
|
||||
expect(fav_319542674.explicit_time).to eq Time.parse(
|
||||
"Dec 22, 2014 05:59 PM -05:00",
|
||||
)
|
||||
expect(fav_319542674.post.fa_id).to eq(15_288_097)
|
||||
|
||||
# the same post is listed twice, it should be deduplicated to the larger fav_fa_id
|
||||
fav_313566473 = user.user_post_favs.find { |f| f.fav_id == 313_566_473 }
|
||||
fav_313566473 =
|
||||
user.user_post_favs.find { |f| f.fa_fav_id == 313_566_473 }
|
||||
expect(fav_313566473.explicit_time).to be_nil
|
||||
expect(fav_313566473.post.fa_id).to eq(14_971_928)
|
||||
end
|
||||
|
||||
@@ -148,14 +148,14 @@ describe Domain::Fa::Job::UserPageJob do
|
||||
expect(fav_51671587.explicit_time).to eq(
|
||||
Time.parse("Apr 6, 2023 04:28 PM -07:00"),
|
||||
)
|
||||
expect(fav_51671587.fav_id).to be_nil
|
||||
expect(fav_51671587.fa_fav_id).to be_nil
|
||||
|
||||
fav_51617113 = user_post_favs.find { |f| f.post.fa_id == 51_617_113 }
|
||||
expect(fav_51617113.user).to eq(user)
|
||||
expect(fav_51617113.explicit_time).to eq(
|
||||
Time.parse("Apr 2, 2023 02:49 PM -07:00"),
|
||||
)
|
||||
expect(fav_51617113.fav_id).to eq(1_234_567_890)
|
||||
expect(fav_51617113.fa_fav_id).to eq(1_234_567_890)
|
||||
end
|
||||
|
||||
context "the user does not yet exist" do
|
||||
@@ -947,7 +947,7 @@ describe Domain::Fa::Job::UserPageJob do
|
||||
]
|
||||
end
|
||||
|
||||
it "records favs with fav_id and explicit_time" do
|
||||
it "records favs with fa_fav_id and explicit_time" do
|
||||
perform_now({ url_name: "dilgear" })
|
||||
user = Domain::User::FaUser.find_by(url_name: "dilgear")
|
||||
user_post_favs = user.user_post_favs
|
||||
@@ -959,7 +959,7 @@ describe Domain::Fa::Job::UserPageJob do
|
||||
expect(fav_26304.explicit_time).to eq(
|
||||
Time.parse("Feb 17, 2006 07:09 AM -08:00"),
|
||||
)
|
||||
expect(fav_26304.fav_id).to be_nil
|
||||
expect(fav_26304.fa_fav_id).to be_nil
|
||||
end
|
||||
|
||||
context "user has not had a favs scan in the past" do
|
||||
|
||||
@@ -159,7 +159,7 @@ RSpec.describe "Domain::User counter caches", type: :model do
|
||||
|
||||
user.reload
|
||||
expect(user.user_post_favs_count).to be_nil
|
||||
expect(user.user_post_favs.size).to eq(1)
|
||||
expect(user.user_post_favs.size).to eq(0)
|
||||
expect(user.user_post_favs.count).to eq(1)
|
||||
|
||||
# recompute the value of the counter cache
|
||||
@@ -193,7 +193,6 @@ RSpec.describe "Domain::User counter caches", type: :model do
|
||||
expect(user.user_post_creations.count).to eq(2)
|
||||
|
||||
# and a third to test incrementing
|
||||
puts "creating a third post"
|
||||
create(:domain_post_fa_post, creator: user)
|
||||
user.reload
|
||||
expect(user.user_post_creations.count).to eq(3)
|
||||
|
||||
@@ -23,22 +23,6 @@ RSpec.describe Domain::User, type: :model do
|
||||
expect(upf.map(&:post)).to match_array(fa_posts)
|
||||
expect(upf.to_a).to all(be_a(Domain::UserPostFav::FaUserPostFav))
|
||||
end
|
||||
|
||||
it "works correctly for FA users with old fav type" do
|
||||
Domain::UserPostFav.create!(user: fa_user, post: fa_posts.first)
|
||||
expect(fa_user.user_post_favs.length).to eq(1)
|
||||
expect(fa_user.user_post_favs.first).to be_a(Domain::UserPostFav)
|
||||
|
||||
expect do
|
||||
fa_user.upsert_new_favs(fa_posts.map(&:id), log_entry:)
|
||||
# binding.pry
|
||||
end.to change { fa_user.reload.user_post_favs.length }.by(1)
|
||||
|
||||
expect(fa_user.user_post_favs.length).to eq(2)
|
||||
expect(fa_user.user_post_favs.to_a).to all(
|
||||
be_a(Domain::UserPostFav::FaUserPostFav),
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe "E621 users" do
|
||||
|
||||
Reference in New Issue
Block a user