Skip to content

Commit a68d3a8

Browse files
authored
Log id for dnp (#326)
* Add unit test for conditionToDatalog utility function * Refactor getTitleDatalog function to update argument structure - Changed the arguments in the getTitleDatalog function to replace title-related constants with log-related constants. - Updated variable names to reflect the new log ID context. * 1.37.0
1 parent e060b08 commit a68d3a8

4 files changed

Lines changed: 28 additions & 27 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "query-builder",
3-
"version": "1.36.1",
3+
"version": "1.37.0",
44
"description": "Introduces new user interfaces for building queries in Roam",
55
"main": "./build/main.js",
66
"author": {

src/utils/conditionToDatalog.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,8 @@ const getTitleDatalog = ({
6363
type: "data-pattern",
6464
arguments: [
6565
{ type: "variable", value: source },
66-
{ type: "constant", value: ":node/title" },
67-
{ type: "variable", value: `${source}-Title` },
68-
],
69-
},
70-
{
71-
type: "fn-expr",
72-
fn: "re-pattern",
73-
arguments: [
74-
{
75-
type: "constant",
76-
value: `"${DAILY_NOTE_PAGE_TITLE_REGEX.source}"`,
77-
},
78-
],
79-
binding: {
80-
type: "bind-scalar",
81-
variable: { type: "variable", value: `date-regex` },
82-
},
83-
},
84-
{
85-
type: "pred-expr",
86-
pred: "re-find",
87-
arguments: [
88-
{ type: "variable", value: "date-regex" },
89-
{ type: "variable", value: `${source}-Title` },
66+
{ type: "constant", value: ":log/id" },
67+
{ type: "variable", value: `${source}-log-id` },
9068
],
9169
},
9270
];

tests/conditionToDatalog.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { expect, test } from "@playwright/test";
2+
import conditionToDatalog from "../src/utils/conditionToDatalog";
3+
4+
test("has title {date} compiles to :log/id clause", () => {
5+
const clauses = conditionToDatalog({
6+
type: "clause",
7+
uid: "test",
8+
relation: "has title",
9+
source: "node",
10+
target: "{date}",
11+
});
12+
13+
expect(clauses).toEqual([
14+
{
15+
type: "data-pattern",
16+
arguments: [
17+
{ type: "variable", value: "node" },
18+
{ type: "constant", value: ":log/id" },
19+
{ type: "variable", value: "node-log-id" },
20+
],
21+
},
22+
]);
23+
});

0 commit comments

Comments
 (0)