Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
28 changes: 19 additions & 9 deletions src/utils/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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));
},
},
{
Expand Down
Loading