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

Keep a log of all activities, not just the latest activity for each activity type. #48

Merged
merged 1 commit into from
Jan 28, 2024

Conversation

caarmen
Copy link
Owner

@caarmen caarmen commented Jan 21, 2024

Copy all the fields and the data. Don't copy the unique constraint on user + activity type. We'll now log all the users' activities for each supported type, not just one per user and type.

Add a db migration which:

  • creates the new table.
  • populates the new table with the data from the old table.
  • deletes the old table.

Add a crud function to get the latest activity for a given user and type.

  • Use this crud function from the fitbit service, to get the latest activity.
  • Use this crud function from tests, to verify that we correctly inserted a new activity.

Add created_at and updated_at fields to test fixtures, so we can be sure our pre-existing activity data exists with timestamps in the past. Otherwise, the pre-existing activities will be created with the same timestamp (the resolution is seconds) as the new ones created, and the db query to get the latest activity may not always return the new activities.

@caarmen caarmen changed the title wip [WIP 🚧 ] Keep a log of all activities, not just the latest activity for each activity type. Jan 21, 2024
@caarmen caarmen force-pushed the keep-all-activities branch 2 times, most recently from 7b42c0a to c73018e Compare January 21, 2024 19:59
@caarmen caarmen force-pushed the keep-all-activities branch from c73018e to f2e0301 Compare January 21, 2024 21:58
@caarmen caarmen force-pushed the keep-all-activities branch 3 times, most recently from c11e779 to d91f2a7 Compare January 21, 2024 22:27
…ivities`.

Copy all the fields and the data. Don't copy the unique constraint on user + activity type. We'll now log all the users' activities for each supported type, not just one per user and type.

Add a db migration which:
* creates the new table.
* populates the new table with the data from the old table.
* deletes the old table.

Add a crud function to get the latest activity for a given user and type.
* Use this crud function from the fitbit service, to get the latest activity.
* Use this crud function from tests, to verify that we correctly inserted a new activity.

Add a crud function to get the activity for a user with a given log id.
* Use this from the fitbit service, when checking if an activity exists already.

Remove `relationship`s between `FitbitUser` and `FitbitActivity`, to avoid loading all activities for a user.

Add `created_at` and `updated_at` fields to test fixtures, so we can be sure our pre-existing activity data exists with timestamps in the past. Otherwise, the pre-existing activities will be created with the same timestamp (the resolution is seconds) as the new ones created, and the db query to get the latest activity may not always return the new activities.
@caarmen caarmen force-pushed the keep-all-activities branch from d91f2a7 to ca112dd Compare January 21, 2024 22:41
@caarmen caarmen changed the title [WIP 🚧 ] Keep a log of all activities, not just the latest activity for each activity type. Keep a log of all activities, not just the latest activity for each activity type. Jan 28, 2024
@caarmen caarmen marked this pull request as ready for review January 28, 2024 11:38
@caarmen caarmen merged commit cbe7d4a into main Jan 28, 2024
@caarmen caarmen deleted the keep-all-activities branch January 28, 2024 11:38
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

Successfully merging this pull request may close these issues.

1 participant