Commit Graph

74 Commits

Author SHA1 Message Date
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
Sam Lord
37f16b1b17 Added roles to users in data generator
no issue
2023-02-20 09:26:28 +00:00
Sam Lord
36ea0cc6d6 Added labels to data-generator
no issue
2023-02-20 09:26:28 +00:00
Sam Lord
db7ac14467 Added offers to data generator
no issue

Can generate a pair of offers.

TODO: Add offers to the base-data pack
2023-02-20 09:26:28 +00:00
Sam Lord
22ac685354 Added pages to data-generator
no issue

Data generator will now add 3 pages by default - can add extra support here, e.g. webmentions later.
2023-02-20 09:26:28 +00:00
Sam Lord
c6e119ecf5 Allow data-generator to make scheduled and draft posts
no issue

Also adds visiblity options, paid, members-only and public
2023-02-20 09:26:28 +00:00
Sam Lord
10a4a8eb12 Fixed tests for demo-data
no issue
2023-02-17 15:08:01 +00:00
Sam Lord
ca395a958c Added post analytics to data generator
no issue
2023-02-17 14:03:59 +00:00
renovate[bot]
cf7ecb492c
Update dependency c8 to v7.13.0 2023-02-16 22:15:50 +00:00
Sam Lord
b4c90bf07d Reduced number of login events in large-scale data generation
no issue

This should massively increase the speed of importing for the large dataset, which is important as the time to import it on Pro is >10 minutes at the moment
2023-02-16 20:54:14 +00:00