summary refs log tree commit diff
path: root/synapse/storage/events_worker.py
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2019-05-21 11:36:50 -0500
committerGitHub <noreply@github.com>2019-05-21 11:36:50 -0500
commit4a30e4acb4ef14431914bd42ad09a51bd81d6c3e (patch)
tree7857cc1ab121d9255183b51be0e79d8619cc3c8f /synapse/storage/events_worker.py
parentMerge pull request #5203 from matrix-org/erikj/aggregate_by_sender (diff)
downloadsynapse-4a30e4acb4ef14431914bd42ad09a51bd81d6c3e.tar.xz
Room Statistics (#4338)
Diffstat (limited to 'synapse/storage/events_worker.py')
-rw-r--r--synapse/storage/events_worker.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/synapse/storage/events_worker.py b/synapse/storage/events_worker.py
index adc6cf26b5..83ffae2132 100644
--- a/synapse/storage/events_worker.py
+++ b/synapse/storage/events_worker.py
@@ -611,3 +611,27 @@ class EventsWorkerStore(SQLBaseStore):
             return res
 
         return self.runInteraction("get_rejection_reasons", f)
+
+    def _get_total_state_event_counts_txn(self, txn, room_id):
+        """
+        See get_state_event_counts.
+        """
+        sql = "SELECT COUNT(*) FROM state_events WHERE room_id=?"
+        txn.execute(sql, (room_id,))
+        row = txn.fetchone()
+        return row[0] if row else 0
+
+    def get_total_state_event_counts(self, room_id):
+        """
+        Gets the total number of state events in a room.
+
+        Args:
+            room_id (str)
+
+        Returns:
+            Deferred[int]
+        """
+        return self.runInteraction(
+            "get_total_state_event_counts",
+            self._get_total_state_event_counts_txn, room_id
+        )