Skip to content
Open
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
10 changes: 10 additions & 0 deletions js/ffs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ export function ffs_construct_query(
)
return `(newer:"{{date:${val}}}")`;
return `(newer:"${val}")`;
case "older":
if (
condition.val.match(
/^-?\d+ ?(seconds?|minutes?|hours?|days?|weeks?|months?|years?)?$/
)
)
return `(if: timestamp() <= date("{{date:${val}}}"))`;
return `(if: timestamp() <= date("${val}"))`;
case "user":
return `(user:"${val}")`;
case "uid":
Expand Down Expand Up @@ -252,6 +260,8 @@ export function ffs_construct_query(
return quote_comment_str(`id:${quotes(condition.val)}`);
case "newer":
return quote_comment_str(`newer:${quotes(condition.val)}`);
case "older":
return quote_comment_str(`older:${quotes(condition.val)}`);
case "user":
return quote_comment_str(`user:${quotes(condition.val)}`);
case "uid":
Expand Down
2 changes: 1 addition & 1 deletion js/ffs/ffs.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ osm_type
= "node" / "way" / "relation"

meta // TODO?
= x:("user" / "uid" / "newer" / "id") _ ":" _ y:string
= x:("user" / "uid" / "newer" / "older" / "id") _ ":" _ y:string
{ return { query:"meta", meta:x, val:y } }

free_form
Expand Down
13 changes: 13 additions & 0 deletions tests/test.ffs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,19 @@ describe("ide.ffs", () => {
`node(newer:"date:1day")(bbox);${out_str}`
);
});
// older
it("older", async () => {
// regular
let search = 'older:"2000-01-01T01:01:01Z" and type:node';
await expect(construct_query(search)).resolves.to.equal(
`node(if: timestamp() <= date("2000-01-01T01:01:01Z"))(bbox);${out_str}`
);
// relative
search = "older:1day and type:node";
await expect(construct_query(search)).resolves.to.equal(
`node(if: timestamp() <= date("date:1day"))(bbox);${out_str}`
);
});
// user
it("user", async () => {
// user name
Expand Down