Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LABS-24: Remove Now from Index bindings #75

Merged
merged 1 commit into from Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/fauna/queries/fweets.js
Expand Up @@ -108,7 +108,8 @@ function LikeFweet(fweetRef) {
fweet: fweetRef,
like: Var('newLikeStatus'),
refweet: false,
comment: false
comment: false,
created: Now()
}
})
),
Expand Down Expand Up @@ -170,7 +171,8 @@ function Refweet(fweetRef, message, tags) {
fweet: fweetRef,
like: false,
refweet: true,
comment: false
comment: false,
created: Now()
}
})
),
Expand Down Expand Up @@ -235,7 +237,8 @@ function Comment(fweetRef, message) {
fweet: fweetRef,
like: false,
refweet: false,
comment: true
comment: true,
created: Now()
}
})
),
Expand Down
2 changes: 1 addition & 1 deletion src/fauna/setup/followerstats.js
Expand Up @@ -72,7 +72,7 @@ const CreateIndexByUserPopularity = CreateIndex({
refweetsfactor: 1,
postlikes: Select(['data', 'postlikes'], Var('stats')),
postrefweets: Select(['data', 'postrefweets'], Var('stats')),
txtime: Now(),
txtime: Select(['data', 'created'], Var('stats')),
unixstarttime: Time('1970-01-01T00:00:00+00:00'),
ageInSecsSinceUnix: TimeDiff(Var('unixstarttime'), Var('txtime'), 'minutes')
},
Expand Down
10 changes: 1 addition & 9 deletions src/fauna/setup/fweets.js
Expand Up @@ -135,15 +135,7 @@ const CreateIndexFweetsByTag = CreateIndex({
likes: Select(['data', 'likes'], Var('fweet')),
comments: Select(['data', 'comments'], Var('fweet')),
refweets: Select(['data', 'refweets'], Var('fweet')),

// DISCLAIMER !!!!
// Now() should not be used in bindings since it does not provide correct results,
// Something I did not know at the time of writing.
// Instead please use either a created_at time you store on the document
// or an updated time instead. We'll update the app from the moment I find time to test
// an alternative approach.

txtime: Now(),
txtime: Select(['data', 'created'], Var('fweet')),
unixstarttime: Time('1970-01-01T00:00:00+00:00'),
ageInSecsSinceUnix: TimeDiff(Var('unixstarttime'), Var('txtime'), 'minutes')
},
Expand Down