(core) Update the current time in formulas automatically every hour

Summary: Adds a special user action `UpdateCurrentTime` which invalidates an internal engine dependency node that doesn't belong to any table but is 'used' by the `NOW()` function. Applies the action automatically every hour.

Test Plan: Added a Python test for the user action. Tested the interval periodically applying the action manually: {F43312}

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3389
This commit is contained in:
Alex Hall
2022-04-25 22:31:23 +02:00
parent 0beb2898cb
commit dc9e53edc8
8 changed files with 105 additions and 13 deletions

View File

@@ -216,9 +216,9 @@ export class Sharing {
try {
const isCalculate = (userActions.length === 1 &&
userActions[0][0] === 'Calculate');
(userActions[0][0] === 'Calculate' || userActions[0][0] === 'UpdateCurrentTime'));
// `internal` is true if users shouldn't be able to undo the actions. Applies to:
// - Calculate because it's not considered as performed by a particular client.
// - Calculate/UpdateCurrentTime because it's not considered as performed by a particular client.
// - Adding attachment metadata when uploading attachments,
// because then the attachment file may get hard-deleted and redo won't work properly.
const internal = isCalculate || userActions.every(a => a[0] === "AddRecord" && a[1] === "_grist_Attachments");