Skip to content

Commit

Permalink
Merge pull request #75 from ptpaterson/LABS-24
Browse files Browse the repository at this point in the history
LABS-24: Remove Now from Index bindings
  • Loading branch information
rts-rob committed Sep 10, 2021
2 parents 22faeba + 7044648 commit 2c5f0c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
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

0 comments on commit 2c5f0c6

Please sign in to comment.