Commit Graph

7 Commits

Author SHA1 Message Date
Daniel Lockyer
845d3cf759 Fixed generating multiple members_newsletters records
refs https://github.com/TryGhost/DevOps/issues/119

- members_newsletters needs members_subscribe_events, but it was also
  then generating `subscriptions` records and the whole thing was really
  slow
- for now, subscriptions is not a used table so we can remove use of it
- also adds support for generating more than one subscription record
  with an 80% chance of being subscribed
2023-12-07 14:44:00 +01:00
Daniel Lockyer
ff34a98b94 Deduplicated batch insertion code
refs https://github.com/TryGhost/DevOps/issues/119

- this function can simply call the `import` function, which performs
  the same code as we had here
- this makes the code cleaner to read and understand
2023-12-07 14:44:00 +01:00
Daniel Lockyer
76455cb64a Decreased likelihood of duplicate member emails
refs https://github.com/TryGhost/DevOps/issues/119

- we can just expand the range here so it becomes extremely unlikely to
  ever hit duplicate emails
2023-12-07 14:44:00 +01:00
Daniel Lockyer
739c690a29 Fixed generating duplicate newsletter names
refs https://github.com/TryGhost/DevOps/issues/119

- this switches away from using a static list of names in favor of ones
  generated by faker, so we don't run into duplicate names
- also minor code re-arranging
2023-12-07 14:44:00 +01:00
Simon Backx
75bb53f065
🔒 Added support for logging out members on all devices (#18935)
fixes https://github.com/TryGhost/Product/issues/3738
https://www.notion.so/ghost/Member-Session-Invalidation-13254316f2244c34bcbc65c101eb5cc4

- Adds the transient_id column to the members table. This defaults to
email, to keep it backwards compatible (not logging out all existing
sessions)
- Instead of using the email in the cookies, we now use the transient_id
- Updating the transient_id means invalidating all sessions of a member
- Adds an endpoint to the admin api to log out a member from all devices
- Added the `all` body property to the DELETE session endpoint in the
members API. Setting it to true will sign a member out from all devices.
- Adds a UI button in Admin to sign a member out from all devices
- Portal 'sign out of all devices' will not be added for now

Related changes (added because these areas were affected by the code
changes):
- Adds a serializer to member events / activity feed endpoints - all
member fields were returned here, so the transient_id would also be
returned - which is not needed and bloats the API response size
(`transient_id` is not a secret because the cookies are signed)
- Removed `loadMemberSession` from public settings browse (not used
anymore + bad pattern)

Performance tests on site with 50.000 members (on Macbook M1 Pro):
- Migrate: 6s (adding column 4s, setting to email is 1s, dropping
nullable: 1s)
- Rollback: 2s
2023-11-15 17:10:28 +01:00
Sam Lord
356256067c Data generator: Ensure order of newsletters is correct
no issue
2023-08-04 13:36:09 +01:00
Sam Lord
4ff467794f Entirely rewrote data generator to simplify codebase
refs: https://github.com/TryGhost/DevOps/issues/11

This is a pretty huge commit, but the relevant points are:
* Each importer no longer needs to be passed a set of data, it just gets the data it needs
* Each importer specifies its dependencies, so that the order of import can be determined at runtime using a topological sort
* The main data generator function can just tell each importer to import the data it has

This makes working on the data generator much easier.

Some other benefits are:
* Batched importing, massively speeding up the whole process
* `--tables` to set the exact tables you want to import, and specify the quantity of each
2023-08-04 13:36:09 +01:00