mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Fixed the model update method
refs https://github.com/TryGhost/Ghost/pull/14197 - Uses the right method to update a model (`edit`) - Also fixes the `updateLastSeenAt` comment that wasn't reflecting the code
This commit is contained in:
parent
0ad1e65ff6
commit
30681319b5
2 changed files with 10 additions and 10 deletions
|
@ -33,10 +33,10 @@ class LastSeenAtUpdater {
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates the member.last_seen_at field if it wasn't updated in the current UTC day yet
|
||||
* Example: current time is 2022-02-28 18:00:00 UTC
|
||||
* - memberLastSeenAt is 2022-02-27 23:00:00 UTC, timestamp is current time, then `last_seen_at` is set to the current time
|
||||
* - memberLastSeenAt is 2022-02-28 01:00:00 UTC, timestamp is current time, then `last_seen_at` isn't changed
|
||||
* Updates the member.last_seen_at field if it wasn't updated in the current day yet (in the publication timezone)
|
||||
* Example: current time is 2022-02-28 18:00:00
|
||||
* - memberLastSeenAt is 2022-02-27 23:00:00, timestamp is current time, then `last_seen_at` is set to the current time
|
||||
* - memberLastSeenAt is 2022-02-28 01:00:00, timestamp is current time, then `last_seen_at` isn't changed
|
||||
* @param {string} memberId The id of the member to be udpated
|
||||
* @param {string} memberLastSeenAt The previous last_seen_at property value for the current member
|
||||
* @param {Date} timestamp The event timestamp
|
||||
|
@ -44,7 +44,7 @@ class LastSeenAtUpdater {
|
|||
async updateLastSeenAt(memberId, memberLastSeenAt, timestamp) {
|
||||
const timezone = this._settingsCacheService.get('timezone');
|
||||
if (memberLastSeenAt === null || moment(moment.utc(timestamp).tz(timezone).startOf('day')).isAfter(memberLastSeenAt)) {
|
||||
await this._memberModel.update({
|
||||
await this._memberModel.edit({
|
||||
last_seen_at: moment.utc(timestamp).format('YYYY-MM-DD HH:mm:ss')
|
||||
}, {
|
||||
id: memberId
|
||||
|
|
|
@ -18,7 +18,7 @@ describe('LastSeenAtUpdater', function () {
|
|||
new LastSeenAtUpdater({
|
||||
models: {
|
||||
Member: {
|
||||
update: spy
|
||||
edit: spy
|
||||
}
|
||||
},
|
||||
services: {
|
||||
|
@ -44,7 +44,7 @@ describe('LastSeenAtUpdater', function () {
|
|||
new LastSeenAtUpdater({
|
||||
models: {
|
||||
Member: {
|
||||
update: spy
|
||||
edit: spy
|
||||
}
|
||||
},
|
||||
services: {
|
||||
|
@ -66,7 +66,7 @@ describe('LastSeenAtUpdater', function () {
|
|||
new LastSeenAtUpdater({
|
||||
models: {
|
||||
Member: {
|
||||
update: spy
|
||||
edit: spy
|
||||
}
|
||||
},
|
||||
services: {
|
||||
|
@ -92,7 +92,7 @@ describe('LastSeenAtUpdater', function () {
|
|||
new LastSeenAtUpdater({
|
||||
models: {
|
||||
Member: {
|
||||
update: spy
|
||||
edit: spy
|
||||
}
|
||||
},
|
||||
services: {
|
||||
|
@ -113,7 +113,7 @@ describe('LastSeenAtUpdater', function () {
|
|||
new LastSeenAtUpdater({
|
||||
models: {
|
||||
Member: {
|
||||
update: spy
|
||||
edit: spy
|
||||
}
|
||||
},
|
||||
services: {
|
||||
|
|
Loading…
Add table
Reference in a new issue