mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Keep track of row counts per table
Summary: Displays a live row count of each table on the Raw Data page. Test Plan: Browser tests. Reviewers: alexmojaki Reviewed By: alexmojaki Differential Revision: https://phab.getgrist.com/D3540
This commit is contained in:
@@ -1262,11 +1262,13 @@ class Engine(object):
|
||||
self._unused_lookups.add(lookup_map_column)
|
||||
|
||||
def count_rows(self):
|
||||
return sum(
|
||||
table._num_rows()
|
||||
for table_id, table in six.iteritems(self.tables)
|
||||
if useractions.is_user_table(table_id) and not table._summary_source_table
|
||||
)
|
||||
result = {"total": 0}
|
||||
for table_rec in self.docmodel.tables.all:
|
||||
if useractions.is_user_table(table_rec.tableId):
|
||||
count = self.tables[table_rec.tableId]._num_rows()
|
||||
result[table_rec.id] = count
|
||||
result["total"] += count
|
||||
return result
|
||||
|
||||
def apply_user_actions(self, user_actions, user=None):
|
||||
"""
|
||||
|
||||
@@ -1266,7 +1266,7 @@ class TestUserActions(test_engine.EngineTestCase):
|
||||
for i in range(20):
|
||||
self.add_record("Address", None)
|
||||
self.assertEqual(i + 1, table._num_rows())
|
||||
self.assertEqual(i + 1, self.engine.count_rows())
|
||||
self.assertEqual({1: i + 1, "total": i + 1}, self.engine.count_rows())
|
||||
|
||||
def test_raw_view_section_restrictions(self):
|
||||
# load_sample handles loading basic metadata, but doesn't create any view sections
|
||||
|
||||
Reference in New Issue
Block a user