Skip to content

Enable recency checks in sifting patterns #2

@mkremins

Description

@mkremins

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions