2020-01-16 20:01:12 +03:00
|
|
|
import Model, {attr, belongsTo} from '@ember-data/model';
|
2020-11-26 20:19:05 +03:00
|
|
|
import {computed} from '@ember/object';
|
2019-11-25 16:20:16 +03:00
|
|
|
import {equal} from '@ember/object/computed';
|
2019-11-07 11:37:26 +03:00
|
|
|
|
|
|
|
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'),
|
2020-11-26 20:19:05 +03:00
|
|
|
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'),
|
2022-09-29 17:42:45 +03:00
|
|
|
trackClicks: attr('boolean'),
|
2019-11-07 11:37:26 +03:00
|
|
|
|
2022-10-27 10:22:50 +03:00
|
|
|
feedbackEnabled: attr('boolean'),
|
|
|
|
|
2019-11-08 13:07:47 +03:00
|
|
|
createdAtUTC: attr('moment-utc'),
|
2019-11-07 11:37:26 +03:00
|
|
|
createdBy: attr('string'),
|
2019-11-08 13:07:47 +03:00
|
|
|
updatedAtUTC: attr('moment-utc'),
|
2019-11-07 11:37:26 +03:00
|
|
|
updatedBy: attr('string'),
|
|
|
|
|
2019-11-22 18:09:48 +03:00
|
|
|
post: belongsTo('post'),
|
|
|
|
|
2019-11-25 16:20:16 +03:00
|
|
|
isSuccess: equal('status', 'submitted'),
|
|
|
|
isFailure: equal('status', 'failed'),
|
|
|
|
|
2020-11-26 20:19:05 +03:00
|
|
|
openRate: computed('emailCount', 'openedCount', function () {
|
|
|
|
let {emailCount, openedCount} = this;
|
|
|
|
|
|
|
|
if (emailCount === 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Math.round(openedCount / emailCount * 100);
|
|
|
|
}),
|
|
|
|
|
2019-11-22 18:09:48 +03:00
|
|
|
retry() {
|
|
|
|
return this.store.adapterFor('email').retry(this);
|
|
|
|
}
|
2019-11-07 11:37:26 +03:00
|
|
|
});
|