X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=src%2Fdb%2Fpostgres%2Findex.js;h=fc4ec8daa1b229ec353ebfeff8cf5ac3d917a6d8;hb=18eee8e467173aee380bd0727d7065469e706727;hp=d950d4a8488924ea2999a9c03b03d93f38ab4591;hpb=f793d88a96b9495172f5dd0c342f2036c902902d;p=websub-hub diff --git a/src/db/postgres/index.js b/src/db/postgres/index.js index d950d4a..fc4ec8d 100644 --- a/src/db/postgres/index.js +++ b/src/db/postgres/index.js @@ -856,6 +856,18 @@ class DatabasePostgres extends Database { } + async topicPublishHistory(dbCtx, topicId, days) { + const _scope = _fileScope('topicPublishHistory'); + this.logger.debug(_scope, 'called', { topicId, days }); + + const events = await dbCtx.manyOrNone(this.statement.topicPublishHistory, { topicIds: [topicId], daysAgo: days }); + const history = Array.from({ length: days }, () => 0); + events.forEach(({ daysAgo, contentUpdates }) => history[daysAgo] = Number(contentUpdates)); + + return history; + } + + async topicSet(dbCtx, data) { const _scope = _fileScope('topicSet'); this.logger.debug(_scope, 'called', data);