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

Enable recency checks in sifting patterns #2

Open
mkremins opened this issue Dec 27, 2019 · 0 comments
Open

Enable recency checks in sifting patterns #2

mkremins opened this issue Dec 27, 2019 · 0 comments

Comments

@mkremins
Copy link
Member

mkremins commented Dec 27, 2019

Right now it seems like it'll be important for us to be able to ask questions in sifting patterns about how recently a particular event occurred, so that we don't keep dredging up the same old events to ruminate about over and over again.

This can probably be loosely approximated by looking at the event's ID, because DataScript entity IDs are autoincrementing integers. But there's no way that I'm aware of to get the "current timestamp" within a sifting pattern right now, so there's no way to compare these event IDs to some notion of the present moment.

I bet we can implement this using a query function – probably one that calls the newestEID() function we've already defined in sim/util.js. Making this function available to user-defined sifting patterns would require a slight tweak to our DataScript query codegen in Felt core, because custom query functions have to be passed in as part of the query's :in clause.

EDIT: Just remembered that we could also manually maintain a currentTimestep variable in the database and auto-increment it whenever an action is performed. This is probably more elegant but I'm not sure yet where to put the code that's in charge of maintaining it – maybe in Felt core, maybe in the project-specific Sim module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant