mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-23 20:23:08 +02:00
Fix bug
This commit is contained in:
parent
d88f096e6b
commit
45fb451111
1 changed files with 20 additions and 6 deletions
|
@ -4,13 +4,11 @@ const { default: Following } = require('../../../built/models/following');
|
||||||
const { default: FollowingLog } = require('../../../built/models/following-log');
|
const { default: FollowingLog } = require('../../../built/models/following-log');
|
||||||
const { default: FollowedLog } = require('../../../built/models/followed-log');
|
const { default: FollowedLog } = require('../../../built/models/followed-log');
|
||||||
const { default: zip } = require('@prezzemolo/zip')
|
const { default: zip } = require('@prezzemolo/zip')
|
||||||
const html = require('../../../built/text/html').default;
|
|
||||||
const parse = require('../../../built/text/parse').default;
|
|
||||||
|
|
||||||
const migrate = async (following) => {
|
const migrate = async (following) => {
|
||||||
const followingCount = await Following.count({
|
const followingCount = await Following.count({
|
||||||
followerId: following.followerId,
|
followerId: following.followerId,
|
||||||
_id: { $lt: following._id },
|
createdAt: { $lt: following.createdAt },
|
||||||
$or: [
|
$or: [
|
||||||
{ deletedAt: { $exists: false } },
|
{ deletedAt: { $exists: false } },
|
||||||
{ deletedAt: { $gt: following.createdAt } }
|
{ deletedAt: { $gt: following.createdAt } }
|
||||||
|
@ -24,7 +22,7 @@ const migrate = async (following) => {
|
||||||
|
|
||||||
const followersCount = await Following.count({
|
const followersCount = await Following.count({
|
||||||
followeeId: following.followeeId,
|
followeeId: following.followeeId,
|
||||||
_id: { $lt: following._id },
|
createdAt: { $lt: following.createdAt },
|
||||||
$or: [
|
$or: [
|
||||||
{ deletedAt: { $exists: false } },
|
{ deletedAt: { $exists: false } },
|
||||||
{ deletedAt: { $gt: following.createdAt } }
|
{ deletedAt: { $gt: following.createdAt } }
|
||||||
|
@ -37,16 +35,32 @@ const migrate = async (following) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (following.deletedAt) {
|
if (following.deletedAt) {
|
||||||
|
const followingCount2 = await Following.count({
|
||||||
|
followerId: following.followerId,
|
||||||
|
createdAt: { $lt: following.deletedAt },
|
||||||
|
$or: [
|
||||||
|
{ deletedAt: { $exists: false } },
|
||||||
|
{ deletedAt: { $gt: following.createdAt } }
|
||||||
|
]
|
||||||
|
});
|
||||||
await FollowingLog.insert({
|
await FollowingLog.insert({
|
||||||
createdAt: following.deletedAt,
|
createdAt: following.deletedAt,
|
||||||
userId: following.followerId,
|
userId: following.followerId,
|
||||||
count: followingCount - 1
|
count: followingCount2 - 1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const followersCount2 = await Following.count({
|
||||||
|
followeeId: following.followeeId,
|
||||||
|
createdAt: { $lt: following.deletedAt },
|
||||||
|
$or: [
|
||||||
|
{ deletedAt: { $exists: false } },
|
||||||
|
{ deletedAt: { $gt: following.createdAt } }
|
||||||
|
]
|
||||||
|
});
|
||||||
await FollowedLog.insert({
|
await FollowedLog.insert({
|
||||||
createdAt: following.deletedAt,
|
createdAt: following.deletedAt,
|
||||||
userId: following.followeeId,
|
userId: following.followeeId,
|
||||||
count: followersCount - 1
|
count: followersCount2 - 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue