display history of topic updates on topic details page
[websub-hub] / src / db / sqlite / index.js
index b8826a4f15ee424113e72fd790b41b8212bf3cf8..cc4ea90af056db2c99f747f2705e25829801749a 100644 (file)
@@ -822,6 +822,18 @@ class DatabaseSQLite extends Database {
   }
 
 
+  topicPublishHistory(dbCtx, topicId, days) {
+    const _scope = _fileScope('topicPublishHistory');
+    this.logger.debug(_scope, 'called', { topicId, days })
+
+    const events = this.statement.topicPublishHistory.all({ topicId, daysAgo: days });
+    const history = Array.from({ length: days }, () => 0);
+    events.forEach(({ daysAgo, contentUpdates }) => history[daysAgo] = contentUpdates);
+
+    return history;
+  }
+
+
   topicSet(dbCtx, data) {
     const _scope = _fileScope('topicSet');
     this.logger.debug(_scope, 'called', data);