Commit Graph

7 Commits

Author SHA1 Message Date
Thibaut Patel
30681319b5 Fixed the model update method
refs https://github.com/TryGhost/Ghost/pull/14197

- Uses the right method to update a model (`edit`)
- Also fixes the `updateLastSeenAt` comment that wasn't reflecting the code
2022-03-01 17:35:02 +01:00
Thibaut Patel
c12c638974 Fixed typo in members-events-service dependency
refs https://github.com/TryGhost/Ghost/pull/14197

- `domainEvents` should be plural
2022-03-01 17:19:34 +01:00
Thibaut Patel
88f8b622f1 Moved the DomainEvents service as a dependency of members-events-service
refs https://github.com/TryGhost/Ghost/pull/14197

- Using the package directly was creating a second instance and was never triggering the subscriber
- Passing DomainEvents as a dependency solves this issue
2022-03-01 17:12:59 +01:00
Thibaut Patel
36bb014fc0 Simplified time comparison in last-seen-at-updater
no issue

- The code had un-needed complexity
- Removing the extra complexity led to the same behavior, as validated by the unit tests
2022-03-01 13:07:37 +01:00
Thibaut Patel
bc5b8109e6 Moved the last-seen-at-updater to use the publication timezone
refs https://github.com/TryGhost/Team/issues/1306

- This removes the limitation described in commit ff46449ad6
- The only edge case is that when a publication changes their timezone, it will have maximum 24 hours where the member last_seen_at could be incorrect
2022-03-01 10:28:45 +01:00
Thibaut Patel
d2d7fb3fe7 Moved from a floating 24h window to a UTC-aligned window
refs https://github.com/TryGhost/Ghost/pull/14197

- Moved from updating the last_seen_at value "at most every 24h" to "at most every UTC day".
- It will simplify explaining the following behavior: a publication is set in UTC-10, a user visits at 2pm on Monday and at 1pm on Tuesday, the last_seen_at value is still Monday.
- There is no way to go around the above issue due to the technical constraint of updating the `last_seen_at` value at most once a day.
- This might create database write spikes at midnight UTC
2022-02-28 14:42:17 +01:00
Thibaut Patel
161c0d7330 Added the members-events-service package
refs https://github.com/TryGhost/Team/issues/1306

- Contains all services that listen on member events
- Only contains the last-seen-at-updater service for now
- Listens for `MemberViewEvent` events to update the `member.last_seen_at` timestamp
- Updates after 24hours of the last timestamp to avoid too many writes
- Also updates when the value is NULL
- This is using the existing `last_seen_at` value to avoid an SQL query when no writes are required
2022-02-28 14:42:17 +01:00