1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/models/email.js
Sanne de Vries e883c1ce45
Added email open rate to posts list in admin (#1772)
no issue

- added "Sends" and "Opens" columns to the posts list to see newsletter performance at a glance
- "Sends" will show the type of members sent to (free, paid, all) as a tooltip
- "Opens" shows open rate by default and total opens on hover
2020-11-26 17:19:05 +00:00

47 lines
1.3 KiB
JavaScript

import Model, {attr, belongsTo} from '@ember-data/model';
import {computed} from '@ember/object';
import {equal} from '@ember/object/computed';
export default Model.extend({
error: attr('string'),
html: attr('string'),
plaintext: attr('string'),
stats: attr('json-string'),
status: attr('string'),
subject: attr('string'),
submittedAtUTC: attr('moment-utc'),
uuid: attr('string'),
recipientFilter: attr('string'),
emailCount: attr('number', {defaultValue: 0}),
deliveredCount: attr('number', {defaultValue: 0}),
openedCount: attr('number', {defaultValue: 0}),
failedCount: attr('number', {defaultValue: 0}),
trackOpens: attr('boolean'),
createdAtUTC: attr('moment-utc'),
createdBy: attr('string'),
updatedAtUTC: attr('moment-utc'),
updatedBy: attr('string'),
post: belongsTo('post'),
isSuccess: equal('status', 'submitted'),
isFailure: equal('status', 'failed'),
openRate: computed('emailCount', 'openedCount', function () {
let {emailCount, openedCount} = this;
if (emailCount === 0) {
return 0;
}
return Math.round(openedCount / emailCount * 100);
}),
retry() {
return this.store.adapterFor('email').retry(this);
}
});