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

Clarification to the activity_occurrence column #7

Open
tommiranta opened this issue Nov 19, 2021 · 1 comment
Open

Clarification to the activity_occurrence column #7

tommiranta opened this issue Nov 19, 2021 · 1 comment

Comments

@tommiranta
Copy link

tommiranta commented Nov 19, 2021

In the specification you state that:

The column activity_occurrence represents the number of times a given entity has done that activity, at the time that activity occurred (starting with 1). activity_repeated_at is the timestamp of the next time that same activity occurred for that entity. Both should be NULL if another activity has not yet occurred.

I think that there is a discrepancy between above statement and proposed usage of the activity_occurrence column in the examples section:

They can be used to easily get the first time each customer did an activity (activity_occurrence = 1) and the last time (activity_repeated_at = null). Since these two expressions each return only one row per customer, they're also a very efficient way to get every unique customer that has done an activity.

You'd have to query activity_occurrence = 1 OR activity_occurrence is NULL in order to get the first activity for when there is one or several activities of the same kind for the same customer?

I would appreciate a clarification to this issue. Is it a bug in the spec or something that I do not understand?

@tommiranta
Copy link
Author

I'll further clarify how I interpret the situation. When building an activity schema implementation:

  1. Both fields are NULL when we run transformation SQL queries and insert the results into the activity stream
  2. When we scan the activity stream and fill in the activity_occurrence and activity_repeated_at columns
    • Increment the value of activity_occurrence. Set to 1 if there is only one activity of this kind for the customer
    • Set the ts value of next activity of the same kind to activity_repeated_at leaving the last activity with a NULL value

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