mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Nice summary table IDs
Summary: Changes auto-generated summary table IDs from e.g. `GristSummary_6_Table1` to `Table1_summary_A_B` (meaning `Table1` grouped by `A` and `B`). This makes it easier to write formulas involving summary tables, make API requests, understand logs, etc. Because these don't encode the source table ID as reliably as before, `decode_summary_table_name` now uses the summary table schema info, not just the summary table ID. Specifically, it looks at the type of the `group` column, which is `RefList:<source table id>`. Renaming a source table renames the summary table as before, and now renaming a groupby column renames the summary table as well. Conflicting table names are resolved in the usual way by adding a number at the end, e.g. `Table1_summary_A_B2`. These summary tables are not automatically renamed when the disambiguation is no longer needed. A new migration renames all summary tables to the new scheme, and updates formulas using summary tables with a simple regex. Test Plan: Updated many tests to use the new style of name. Added new Python tests to for resolving conflicts when renaming source tables and groupby columns. Added a test for the migration, including renames in formulas. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3508
This commit is contained in:
@@ -436,7 +436,7 @@ class Engine(object):
|
||||
m = match_counter.MatchCounter(sample)
|
||||
# Iterates through each valid column in the document, counting matches.
|
||||
for c in search_cols:
|
||||
if (not gencode._is_special_table(c.tableId) and
|
||||
if (not (gencode._is_special_table(c.tableId) or c.parentId.summarySourceTable) and
|
||||
column.is_visible_column(c.colId) and
|
||||
not c.type.startswith('Ref')):
|
||||
table = self.tables[c.tableId]
|
||||
@@ -1265,7 +1265,7 @@ class Engine(object):
|
||||
return sum(
|
||||
table._num_rows()
|
||||
for table_id, table in six.iteritems(self.tables)
|
||||
if useractions.is_user_table(table_id)
|
||||
if useractions.is_user_table(table_id) and not table._summary_source_table
|
||||
)
|
||||
|
||||
def apply_user_actions(self, user_actions, user=None):
|
||||
|
||||
Reference in New Issue
Block a user