mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
40ee2043e0
closes https://linear.app/tryghost/issue/MOM-97 The 30s search content expiry didn't really make sense and caused unnecessary delays and server load now that search will be more widely used within the editor. - replaced concept of time-based expiry with explicit expiry - content still fetched on query if not already loaded or marked as stale - added `.expireContent()` method on search service to allow explicit expiry - updated editor to pre-fetch search content when not already loaded or marked as stale - removes delay when first using internal linking search inside the editor - updated post model to expire search content on save - expires on published post save or delete - expires on publish and unpublish - updated tag model to expire content on create/save/delete - only expires when name or url is changed - updated user model to expire on save/delete - only expires when name or url is changed - does not handle creation because that's done server-side via invites
32 lines
959 B
JavaScript
32 lines
959 B
JavaScript
import ApplicationSerializer from 'ghost-admin/serializers/application';
|
|
import {EmbeddedRecordsMixin} from '@ember-data/serializer/rest';
|
|
import {pluralize} from 'ember-inflector';
|
|
|
|
export default class UserSerializer extends ApplicationSerializer.extend(EmbeddedRecordsMixin) {
|
|
attrs = {
|
|
roles: {embedded: 'always'},
|
|
lastLoginUTC: {key: 'last_seen'},
|
|
createdAtUTC: {key: 'created_at'},
|
|
updatedAtUTC: {key: 'updated_at'}
|
|
};
|
|
|
|
extractSingle(store, primaryType, payload) {
|
|
let root = this.keyForAttribute(primaryType.modelName);
|
|
let pluralizedRoot = pluralize(primaryType.modelName);
|
|
|
|
payload[root] = payload[pluralizedRoot][0];
|
|
delete payload[pluralizedRoot];
|
|
|
|
return super.extractSingle(...arguments);
|
|
}
|
|
|
|
serialize() {
|
|
const json = super.serialize(...arguments);
|
|
|
|
// Read-only virtual properties
|
|
delete json.url;
|
|
|
|
return json;
|
|
}
|
|
}
|