From f7310a136ac584312ae84f4436b46e5f75fc12e5 Mon Sep 17 00:00:00 2001 From: Michael Gartner Date: Tue, 9 Dec 2025 13:34:54 -0600 Subject: [PATCH 1/2] add sorting to active users --- src/utils/core.ts | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/utils/core.ts b/src/utils/core.ts index 0d50b50..d8abdef 100644 --- a/src/utils/core.ts +++ b/src/utils/core.ts @@ -2300,8 +2300,12 @@ export const COMMANDS: { }, { text: "ACTIVEUSERS", - help: "Gets all users who created/edited a block.\n\nDefault is set to the last three month.\n\n1: (Optional) NLP expression for date basis\n\n2: (Optional) Format of Output", - handler: (nlp = "three months ago", format = `[[{text}]]`) => { + help: "Gets all users who created/edited a block.\n\nDefault is set to the last three month.\n\n1: (Optional) NLP expression for date basis\n\n2: (Optional) Format of Output\n\n3: (Optional) Sort (ASC,DESC,NONE)", + handler: ( + nlp = "three months ago", + format = `[[{text}]]`, + sort = "NONE" + ) => { const timestamp = parseNlpDate(nlp, getDateBasisDate()).valueOf() || // chrono fails basic parsing requiring forward date if ambiguous @@ -2322,13 +2326,19 @@ export const COMMANDS: { [(< ${timestamp} ?time)] ] `) as [PullBlock, PullBlock][] - ).map(([user]) => { - return getFormatter(format)({ - text: user[":node/title"], - uid: user[":block/uid"], - }); - }); - return activeUsers; + ).map(([user]) => ({ + text: user[":node/title"] || user[":block/uid"] || "", + uid: user[":block/uid"], + })); + const sortedUsers = + sort === "NONE" + ? activeUsers + : activeUsers.sort( + sort === "DESC" + ? (a, b) => b.text.localeCompare(a.text) + : (a, b) => a.text.localeCompare(b.text) + ); + return sortedUsers.map((user) => getFormatter(format)(user)); }, }, { From c0ee04be02a3b7bc6ecee02faabaacd50976517b Mon Sep 17 00:00:00 2001 From: Michael Gartner Date: Tue, 9 Dec 2025 14:02:51 -0600 Subject: [PATCH 2/2] 1.12.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9456a3d..490e832 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "smartblocks", - "version": "1.12.1", + "version": "1.12.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "smartblocks", - "version": "1.12.1", + "version": "1.12.2", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 884d965..5917cab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "smartblocks", - "version": "1.12.1", + "version": "1.12.2", "description": "Create custom and programmable templates from within Roam!", "main": "./build/main.js", "scripts": {