Make migration scripts
and use createdAt instead of _id
This commit is contained in:
@ -6,6 +6,7 @@ export default FollowedLog;
|
||||
|
||||
export type IFollowedLog = {
|
||||
_id: ObjectID;
|
||||
createdAt: Date;
|
||||
userId: ObjectID;
|
||||
count: number;
|
||||
};
|
||||
|
@ -6,6 +6,7 @@ export default FollowingLog;
|
||||
|
||||
export type IFollowingLog = {
|
||||
_id: ObjectID;
|
||||
createdAt: Date;
|
||||
userId: ObjectID;
|
||||
count: number;
|
||||
};
|
||||
|
@ -24,6 +24,7 @@ export default ({ data }, done) => Following.findOne({ _id: data.following }).th
|
||||
}),
|
||||
|
||||
promisedFollower.then(({ followingCount }) => FollowingLog.insert({
|
||||
createdAt: data.following.createdAt,
|
||||
userId: followerId,
|
||||
count: followingCount + 1
|
||||
})),
|
||||
@ -36,6 +37,7 @@ export default ({ data }, done) => Following.findOne({ _id: data.following }).th
|
||||
}),
|
||||
|
||||
promisedFollowee.then(({ followersCount }) => FollowedLog.insert({
|
||||
createdAt: data.following.createdAt,
|
||||
userId: followerId,
|
||||
count: followersCount + 1
|
||||
})),
|
||||
|
@ -42,10 +42,10 @@ module.exports = (params) => new Promise(async (res, rej) => {
|
||||
|
||||
for (let i = 0; i < 30; i++) {
|
||||
graph.push(FollowedLog.findOne({
|
||||
_id: { $lt: ObjectID.createFromTime(cursorTime / 1000) },
|
||||
createdAt: { $lt: new Date(cursorTime / 1000) },
|
||||
userId: user._id
|
||||
}, {
|
||||
sort: { _id: -1 },
|
||||
sort: { createdAt: -1 },
|
||||
}).then(log => {
|
||||
cursorDate = new Date(today.getTime());
|
||||
cursorTime = cursorDate.setDate(today.getDate() - i);
|
||||
|
@ -42,10 +42,10 @@ module.exports = (params) => new Promise(async (res, rej) => {
|
||||
|
||||
for (let i = 0; i < 30; i++) {
|
||||
graph.push(FollowingLog.findOne({
|
||||
_id: { $lt: ObjectID.createFromTime(cursorTime / 1000) },
|
||||
createdAt: { $lt: new Date(cursorTime / 1000) },
|
||||
userId: user._id
|
||||
}, {
|
||||
sort: { _id: -1 },
|
||||
sort: { createdAt: -1 },
|
||||
}).then(log => {
|
||||
cursorDate = new Date(today.getTime());
|
||||
cursorTime = cursorDate.setDate(today.getDate() - i);
|
||||
|
Reference in New Issue
Block a user