Ghost/core/server/models
Kevin Ansfield 426cbeec0f
🐛 Fixed performance regression introduced in 4.1.0 (#12807)
closes https://github.com/TryGhost/Ghost/issues/12791
closes https://github.com/TryGhost/Team/issues/566

https://github.com/TryGhost/Ghost/pull/12787 introduced a significant performance regression due to a misunderstanding of when Bookshelf calls `.format()` ([related upstream issue](https://github.com/bookshelf/bookshelf/issues/668)). We expected `.format()` to only be called on save but it's also called when Bookshelf performs fetching and eager loading which happens frequently. `.format()` can be a heavy method as it needs to parse and serialize html and markdown so it should be performed as infrequently as possible.

- override `sync()` in the base model so we can call our own `.formatOnWrite()` method to transform attributes on `update` and `insert` operations
  - this was the only feasible location in Bookshelf I could find that is low enough level to not require modifying model instance attributes
  - gives models the option to perform heavy transform operations only when writing to the database compared to the usual `.format()` method that is also called on fetch in many situations
2021-03-23 09:11:24 +00:00
..
base 🐛 Fixed performance regression introduced in 4.1.0 (#12807) 2021-03-23 09:11:24 +00:00
plugins Added email.open_rate order option to posts api (#12439) 2020-12-03 20:13:37 +00:00
relations Extracted promise libs and history into @tryghost/promise 2020-08-11 18:44:21 +01:00
action.js Added model implementation for actions 2019-02-06 21:36:09 +01:00
api-key.js Added the user_id field to the api_keys table 2020-11-20 09:53:18 +01:00
author.js Added plugin based author and public tag models in API v2 (#10284) 2019-01-03 20:30:35 +01:00
email-batch.js Fixed creation of EmailBatch and EmailRecipient collections 2020-10-14 15:11:45 +01:00
email-recipient.js Removed unnecessary bookshelf-relations config in EmailRecipient model 2021-01-05 15:28:30 +00:00
email.js Added migrations for email analytics (#12387) 2020-11-25 17:48:24 +00:00
index.js Added MemberPaidSubscriptionEvent model 2021-02-12 13:55:14 +00:00
integration.js Updated host config to correctly use camelCase 2021-03-04 11:39:32 +00:00
invite.js 🐛 Allowed for inviting contributors when staff is limited 2021-03-15 11:40:44 +00:00
label.js Refactored common lib import to use destructuring (#11835) 2020-05-22 19:22:20 +01:00
member-email-change-event.js Added member relation to events (#12656) 2021-02-16 16:14:20 +00:00
member-login-event.js Added member relation to events (#12656) 2021-02-16 16:14:20 +00:00
member-paid-subscription-event.js Added member relation to events (#12656) 2021-02-16 16:14:20 +00:00
member-payment-event.js Added member relation to events (#12656) 2021-02-16 16:14:20 +00:00
member-status-event.js Fixed member status events query 2021-02-18 18:11:50 +05:30
member-stripe-customer.js Added error handling for failed member imports 2020-08-26 17:11:35 +12:00
member-subscribe-event.js Added member relation to events (#12656) 2021-02-16 16:14:20 +00:00
member.js 🐛 Fixed Member model removing labels when unset 2021-02-08 09:39:46 +00:00
mobiledoc-revision.js Added mobiledoc revisions functionality 2018-10-09 15:31:09 +02:00
permission.js Updated var declarations to const/let and no lists 2020-04-29 16:51:13 +01:00
post.js 🐛 Fixed performance regression introduced in 4.1.0 (#12807) 2021-03-23 09:11:24 +00:00
posts-meta.js 🐛 Fixed performance regression introduced in 4.1.0 (#12807) 2021-03-23 09:11:24 +00:00
role.js Refactored common lib import to use destructuring (#11835) 2020-05-22 19:22:20 +01:00
session.js Removed user_id constraint when upserting session (#10085) 2018-10-30 16:15:48 +07:00
settings.js 🐛 Fixed performance regression introduced in 4.1.0 (#12807) 2021-03-23 09:11:24 +00:00
single-use-token.js 🐛 Added multiple use grace period to tokens (#12519) 2021-01-18 17:03:41 +00:00
snippet.js 🐛 Fixed performance regression introduced in 4.1.0 (#12807) 2021-03-23 09:11:24 +00:00
stripe-customer-subscription.js Removed hardcoded currency symbols (#12700) 2021-02-25 09:49:07 +00:00
tag-public.js Added plugin based author and public tag models in API v2 (#10284) 2019-01-03 20:30:35 +01:00
tag.js 🐛 Fixed performance regression introduced in 4.1.0 (#12807) 2021-03-23 09:11:24 +00:00
user.js 🐛 Fixed __GHOST_URL__ appearing in sitemaps (#12787) 2021-03-18 17:16:37 +00:00
webhook.js Bumped webhook API defaults to v4 2021-03-02 12:31:52 +13:00