Commit Graph

83 Commits

Author SHA1 Message Date
Daniel Lockyer
be6b9e437f Refactored fetching schema tables in data generator
- we want to pass in the schema tables instead of cross requiring them
  from a different package because it means the package isn't standalone
  and moving the code structure around breaks the data generator
2024-01-13 18:28:14 +01:00
Simon Backx
d2cb23c3fa
Wired up Docker setup script and increased data generation performance (#19420)
ref PROD-233

- Stored whether Docker is used in the config files
- When running `yarn setup`, any existing Docker container will be
reset. Run with `-y` to skip the confirmation step.
- `yarn setup` will always init the database and generate fake data
- Increased amount of default generated data to 100,000 members + 500
posts.
- Made lots of performance improvements in the data generator so we can
generate the default data in ±170s
2024-01-05 13:42:30 +00:00
Simon Backx
54e3abfbc2
Added generator referrer attribution for paid subscriptions (#19419)
ref PROD-244
2024-01-02 11:29:24 +00:00
Simon Backx
4c9d08bf03 Fixed data generator in SQLite 2023-12-14 18:30:45 +01:00
Simon Backx
70b991cc1c Improved subscriptions in data generator
ref PROD-244

- Added support for canceled subscriptions and different subscription statusses
- Removed generation of susbcriptions table (not used)
- Added old canceled subscriptions for free members
- Added both positive and negative MRR events
2023-12-14 18:30:45 +01:00
Simon Backx
5351b88b59 Added random expiry date for complimentary subscriptions in data generator
ref PROD-244
2023-12-14 18:30:45 +01:00
Simon Backx
e1ef7c44d8 Fixed creating stripe subscriptions for complimentary members in data generator
ref PROD-244
2023-12-14 18:30:45 +01:00
Simon Backx
58d1412d9b Added referrer attribution and fixed data generator for scheduled posts
ref PROD-244

Scheduled posts should have a published_at set to the future
2023-12-14 18:30:45 +01:00
Simon Backx
58f23726fe Added recommendation click and subscribe events to data generator
ref PROD-244
2023-12-14 18:30:45 +01:00
Simon Backx
50788a78df Added recommendations data generator
ref PROD-244
2023-12-14 18:30:45 +01:00
Simon Backx
6f3a22d0a7 Added email_recipient_failures to data generator
ref PROD-244
2023-12-14 18:30:45 +01:00
Simon Backx
54eb3e5b08 Added generated amount to debug logs 2023-12-14 18:30:45 +01:00
Simon Backx
8a01e7a076 Improved batch and recipient data generation
ref PROD-244

Instead of generating one batch with all recipients, we now will generate
one batch per 1000 members and distribute the recipients across them.
2023-12-14 18:30:45 +01:00
Simon Backx
52566dc1e0 Wrapped data generator data creation in transaction function
ref PROD-233

Errors were not handled properly because of a missing rollback and try/catch.

Using a function is easier generally.

Also added ignored contraint checks to increase performance a tiny bit.
They ended up not mattering much, so we can consider to remove them again.
2023-12-14 18:30:45 +01:00
Simon Backx
a3bbd579dd Improved data generator clear data performance
ref PROD-233
2023-12-14 18:30:45 +01:00
Simon Backx
60fb2e3139
Added quantities and seed option to the data generator (#19330)
ref PROD-243
2023-12-12 12:50:55 +01:00
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
db16e565bc Added --print-dependencies to data generator
refs https://github.com/TryGhost/DevOps/issues/119

- this allows you to debug the dependency chain to understand why a
  particular table is being generated
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
bb99a4c394 Removed unnecessary await
refs https://github.com/TryGhost/DevOps/issues/119

- this is not needed and tsserver was flagging it up
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
renovate[bot]
057d9599f5 Update TryGhost packages 2023-10-31 20:54:17 +01:00
Daniel Lockyer
85098e07d4 Configured all unit tests to use dot reporter
refs https://ghost.slack.com/archives/C02G9E68C/p1696490748701419

- this configures mocha to use the dot reporter because the default is
  way too verbose in CI
2023-10-05 12:24:24 +02:00
Daniel Lockyer
c6cb35074a Updated linting and testing packages 2023-09-01 15:51:17 +02: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
renovate[bot]
7dce046786 Update Test & linting packages 2023-07-11 15:26:07 +02:00
Fabien "egg" O'Carroll
104f84f252 Added eslint rule for file naming convention
As discussed with the product team we want to enforce kebab-case file names for
all files, with the exception of files which export a single class, in which
case they should be PascalCase and reflect the class which they export.

This will help find classes faster, and should push better naming for them too.

Some files and packages have been excluded from this linting, specifically when
a library or framework depends on the naming of a file for the functionality
e.g. Ember, knex-migrator, adapter-manager
2023-05-09 12:34:34 -04:00
Sam Lord
cb30c9bbc9 Prevent posts_meta data from killing the data-generator process
no issue
2023-05-03 16:28:29 +01:00
Sam Lord
f7188b4dcf Prevented an invalid order during deletion
no issue

Will allow the demo data script to run if offers exist and have been redeemed
2023-05-02 16:34:47 +01:00
renovate[bot]
07545541a8 Update @tryghost 2023-04-07 13:47:12 +02:00
renovate[bot]
83373e1751 Update Test & linting packages 2023-04-05 15:16:08 +02:00
Sam Lord
1d7572fed5 Data generator: Fixed the URL formatting for newsletter clicks
no issue
2023-03-30 16:49:19 +01:00
Sam Lord
661de46ae0 Fixed the reply-to address for newsletters in data generator
no issue

This makes it so that newsletters can be manipulated in Ghost Admin, otherwise Ember errors
2023-03-22 14:56:51 +00:00
Sam Lord
d04b43aeee Added post-based attributions for members in data-generator
no issue
2023-03-16 10:17:14 +00:00
Sam Lord
72ba6ec4af Added member feedback to data generator
refs: https://github.com/TryGhost/Toolbox/issues/454
2023-03-14 10:32:34 +00:00
renovate[bot]
2223db5379
Update Test & linting packages 2023-03-13 02:36:20 +00:00
renovate[bot]
b93b38a8e8 Update @tryghost 2023-03-10 09:52:02 +01:00
Daniel Lockyer
6b1966ad9b Updated sinon dependency
- this is being done manually instead of merging the Renovate PR because
  the PR bundles another bump which doesn't pass yet
2023-03-02 12:43:42 +01:00
renovate[bot]
9f08732039 Update @tryghost 2023-03-02 09:47:02 +01:00
Sam Lord
98f0b6c7ce Added ghost_subscription_id to members_stripe_customers_subscriptions table in data generator
no issue
2023-02-28 11:14:11 +00:00
Sam Lord
9852c21ec5 Prevented random labels from being generated when base-data is present
no issue

Before, when base data included labels for members, the random generated labels would also be generated. This prevents that, and ensures that the base-data labels are applied correctly to members.
2023-02-23 11:04:58 +00:00
Sam Lord
c72dcd629f Fixed balance of email recipient data in data generator
no issue

Previously the number of opened emails was being generated incorrectly as the number of delivered emails was being reported too high.

Also, the faker date function occasionally fails for dates which are
too close together so this switches to manually generating a date
between the two.
2023-02-21 23:50:02 +00:00
Sam Lord
6cdf37c0ee Added open rates to members in data generator
no issue
2023-02-21 23:50:02 +00:00
Sam Lord
522652e99e Prevent duplicate label names in data generator
no issue
2023-02-21 11:42:33 +00:00
Sam Lord
744b92333c Fixed members-click-event created_at time
no issue
The faker date method seems to spontaneously fail sometimes, as it had decided that the "later" time was before the opened time.
2023-02-20 15:46:47 +00:00
Sam Lord
25eaf05395 Made data generator import labels from the base pack when specified
no issue

This will allow us to use a custom (non-random) set of labels, which should look more realistic.
2023-02-20 12:02:44 +00:00
Sam Lord
70e2c07f2e Data generator: Ensure user roles are only generated if roles already exist
no issue

Fixes the build, as in the test environment there are no user roles
2023-02-20 11:06:18 +00:00