Commit Graph

36 Commits

Author SHA1 Message Date
Princi Vershwal
309cb37cc6
Updated nql package (#20811)
Ref [ONC-216](https://linear.app/tryghost/issue/ONC-216/improve-the-performance-of-the-membersevents-aggregated-click-event)

Needed changes in nql package for this task.
2024-08-22 07:55:14 +00:00
renovate[bot]
4b28812861 Update TryGhost packages 2024-08-05 12:12:34 +02:00
renovate[bot]
3ebe206ea7 Update TryGhost packages 2024-05-27 16:58:32 +02:00
Steve Larson
842290cbef
Improved performance for filter strings with multiple neq statements (#20198)
ref https://linear.app/tryghost/issue/CFR-27
- updated packages to include performance improvement for NQL filter
strings including multiple neq filters for the same resource
- bumped `bookshelf-plugins`
- bumped NQL versions

We identified a performance fix that allows us to combine not equal
(neq) filters for the same resource in a logically-equivalent way that
also has far more performant resulting SQL.

We're effectively automatically combining strings like
'tag:-tag1+tag:-tag2` into 'tag:-[tag1,tag2]'.
2024-05-13 10:35:27 -05:00
renovate[bot]
a33dccf8cd Update TryGhost packages 2024-05-01 17:01:41 +02:00
renovate[bot]
60a3b5a913 Update TryGhost packages 2024-05-01 08:49:04 +02:00
Steve Larson
a1c4e64994
Added queueing middleware to handle high request volume (#19887)
ref https://linear.app/tryghost/issue/CFR-4/
- added request queueing middleware (express-queue) to handle high
request volume
- added new config option `optimization.requestQueue`
- added new config option `optimization.requestConcurrency`
- added logging of request queue depth - `req.queueDepth`

We've done a fair amount of investigation around improving Ghost's
resiliency to high request volume. While we believe this to be partly
due to database connection contention, it also seems Ghost gets
overwhelmed by the requests themselves. Implementing a simple queueing
system allows us a simple lever to change the volume of requests Ghost
is actually ingesting at any given time and gives us options besides
simply increasing database connection pool size.

---------

Co-authored-by: Michael Barrett <mike@ghost.org>
2024-03-21 09:25:07 -05:00
Daniel Lockyer
162f438c63 Updated @tryghost/errors dependency
- this version is written in TS, but was published a few months ago and
  needs to be bumped here
- also updates a previous deep include into the library, which was
  unnecessary anyway
2024-03-11 17:33:51 +01:00
Michael Barrett
ed0762fb51
Removed usage of yg when using NQL (#19287)
refs https://github.com/TryGhost/NQL/pull/73

The referenced PR removes `yg` from the parsed NQL output, so we also
need to remove any usage of it in Ghost
2024-01-15 14:40:01 +00:00
Simon Backx
e5f644c27f
🐛 Fixed contain/starts/endsWith filters with /, _ or % in them (#19015)
fixes GRO-25

Updated @tryghost/nql to 0.12.0 and other packages that depend on it

1. SQLite: when a filter string contains /.

When we use a NQL contain/starts/endsWith filter that contains a slash,
underlyingly the whole filter will get converted to a MongoDB query, in
which we just use a regexp to represent the filter. In here we will
escape the slash: \/ as expected in a regexp. Later when we convert this
MongoDB query back to knex/SQL, we use a SQL LIKE query. Currently we
don't remove the escaping here for a normal slash. MySQL seems to ignore
this (kinda incorrect). SQLite doesn't like it, and this breaks queries
on SQLite that use slashes. The solution here is simple: remove the
backslash escaping when converting the regexp to LIKE, just like we do
with other special regexp characters.

2. We don't escape % and _, which have a special meaning in LIKE queries

Usage of % and _ is now as expected and doesn't have the special SQL
meaning anymore.
2023-11-16 09:35:20 +00:00
renovate[bot]
057d9599f5 Update TryGhost packages 2023-10-31 20:54:17 +01:00
Daniel Lockyer
85d41d0562 Aligned dependencies with resolution values
- this commit brings all dependencies up-to-date with the version set as
  a resolution
2023-10-13 08:37:36 +02: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
Naz
367584f1c2 Optimized PostEditedEvent processing in collections
refs https://github.com/TryGhost/Arch/issues/86

- When PostEditedEvent data contains no visible changes we can skip the matching collections update process alltogether. Each call to `updatePostInMatchingCollections` creates a transaction in addition to fetching all collections. There's no need to process anything when there are no relevant changes in the post edit!
2023-09-08 13:46:44 +08:00
Daniel Lockyer
c6cb35074a Updated linting and testing packages 2023-09-01 15:51:17 +02:00
Naz
608d4dfa10 Optimized the amount of logs produced by collections module
refs https://github.com/TryGhost/Arch/issues/82

- Collections logs are too verbose causing noise.
- Moved some of the logs to use "debug" for now and made summarized logs for the information that we still need while collections code is actively monitored. The event info logs can be removed once we are passed the active phase of rolling out the collections feature
2023-09-01 12:40:54 +08:00
Naz
f4143a8939 Fixed build scripts for post-events package 2023-08-01 15:11:00 +08:00
Naz
694ab1d32d Added support for expansions in collection filters
refs https://github.com/TryGhost/Arch/issues/46

- Similarly to post filters, collection filters now support both 'tag' and 'tags' nql filter keys when defining a filter for related tag slugs. For example, both `tag:avocado` and `tags:avocado` would both be valid collection filters that would filter by the same 'slug' property of the tags assigned to a post.
- Along with these changes had to rework the tags property of the collection posts to match the shape used in post resources. Moved from:
`tags: ['bacon', 'broc']`
to
`tags:[{slug: 'bacon'}, {slug: 'broc'}]`
2023-07-25 19:01:56 +08:00
Daniel Lockyer
d5cbb33e54 Pinned dependencies 2023-07-24 16:21:47 +02:00
Daniel Lockyer
bb4c3de992 Deduplicated ts-node and typescript dependencies
refs https://github.com/TryGhost/DevOps/issues/50

- this commit deduplicates where we define the versions of these
  packages to make them easier to maintain
2023-07-24 16:21:47 +02:00
Naz
53f9f954c1 Added tag filter support to collections
refs https://github.com/TryGhost/Arch/issues/41

- When an new collection is created the relational "tags" filter is now picked up properly and appropriate posts matching the tag filter are assigned and stored in the collection. Example collection filter that is now supported: `tags:['bacon']`
- Additionally cleaned up returned collection post DTOs, so we return as little data as possible and add only the fields that are needed
2023-07-18 20:18:54 +08:00
Daniel Lockyer
2aa7da3a0b Improved monorepo tooling setup
refs https://github.com/TryGhost/DevOps/issues/45

- this switches the monorepo over to using Nx instead of Lerna, because
  we don't currently need the versioning+publishing capabilities
- this also adds an `nx.json`, which allows us to enable task caching
- also adds `build:ts` to the TS projects, which is cached for fast execution
- how these interact with the dev.js script will hopefully soon be
  reworked to be a better experience
2023-07-12 16:27:39 +02:00
renovate[bot]
7dce046786 Update Test & linting packages 2023-07-11 15:26:07 +02:00
renovate[bot]
aa8cbb9fa3 Update dependency typescript to v5.1.6 2023-06-29 08:24:30 +02:00
Fabien "egg" O'Carroll
0a3e36cd62 Ensured uniqueness of slug in collections
We require that slugs are unique as slugs can/are used for routing purposes and
act as an identifier for a resource. As this is a core business rule, we want
to encode it in the entity so that it can be unit tested, and be enforced
regardless of underlying persistence layer
2023-06-29 01:40:05 +01:00
renovate[bot]
58b54333a5 Update dependency typescript to v5.1.5 2023-06-28 16:21:27 +02:00
Naz
5dd6159ac6 Added handling for 'post.edited' Ghost model event
refs https://github.com/TryGhost/Team/issues/3169

- Adds optomized collection update handling for when post.edited model event is emitted.
2023-06-27 12:52:10 +07:00
Naz
623599af1e Moved DomainEvents to be injected to Collections
refs https://github.com/TryGhost/Team/issues/3169

- With the new architecture all possible dependencies should be  injected rather than required directly - this applies to the DomainEvents module as well.
2023-06-27 12:52:10 +07:00
Naz
36783e456b Added 'post.added' event handling in Collections
refs https://github.com/TryGhost/Team/issues/3169

- This piece of logic handles the 'post.added' model event mapping to Collection's PostAddedEvent domain event and logic related to updating collections when the new post is added.
2023-06-27 12:52:10 +07:00
Naz
e7a0462877 Added model event to domain event bridge
refs https://github.com/TryGhost/Team/issues/3169

- To make the coupling to Ghost's model events as loose as possible added a bridge that maps model events to domain events. These domain events it what the collections module can subscribe to to make necessary updates.
2023-06-27 12:52:10 +07:00
renovate[bot]
17acd2437b Update dependency typescript to v5.1.3 2023-06-02 09:06:20 +02:00
Fabien "egg" O'Carroll
5282c4a72b Update eslint and c8 to support using TS interfaces
This will allow us to define the repository interface
2023-06-01 14:25:49 +07:00
Fabien "egg" O'Carroll
b58dac262e Updated collections package to use .d.ts for external lib types
Rather than using `require` we can add a type definition file, this allows us
to add custom types in the future if we want. We need to add some config for
ts-node to pick up the types correctly.
2023-05-24 12:47:20 -04:00
Naz
fdd73d01b7
Refactored collections entity logic
refs https://github.com/TryGhost/Team/issues/3294

- The factory method for the Collection and validations should live close together based on our latest architectural direction
2023-05-24 17:01:28 +07:00
Naz
2d1eb881fc Extended save method to return saved collection data
refs https://github.com/TryGhost/Team/issues/3167

- The core client (API) needs a way to pass in information without an ID when creating a new entity, handling it on service/repository layer makes the most sense.
- Used "require" syntax to import tpl/errors modules, otherwise TS compiler was complaining about type compatibility issues, this works as a temporary workaround and is tracked and an issue to improve in the future.
2023-05-19 20:42:46 +07:00
Naz
4e2a00b6e6 Added a collections package with CRUD logic
closes https://github.com/TryGhost/Team/issues/3166

- The collections service contains CRUD logic to manage collection entities through: save, getById, getAll, and destroy methods.
2023-05-16 12:21:31 +07:00