Skip to content

Commit

Permalink
feat: including TODOs from future daily note pages, #52
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonn committed Apr 23, 2023
1 parent 38422f3 commit 035ebac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
8 changes: 2 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ function App() {
{settings.showNextNDaysTask && (
<TaskSection
title={`Next ${settings.numberOfNextNDays} Days`}
query={getNextNDaysTaskQuery(
settings.numberOfNextNDays,
customMarkers,
)}
query={getNextNDaysTaskQuery(settings.numberOfNextNDays)}
/>
)}
<TaskSection
Expand All @@ -116,9 +113,8 @@ function App() {
settings.showNextNDaysTask
? getScheduledTaskQuery(
dayjs().add(settings.numberOfNextNDays, 'd'),
customMarkers,
)
: getScheduledTaskQuery(dayjs(), customMarkers)
: getScheduledTaskQuery()
}
/>
<TaskSection
Expand Down
8 changes: 2 additions & 6 deletions src/querys/next-n-days.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import dayjs from 'dayjs';

export default function getNextNDaysTaskQuery(
days: number,
customMarkers: string[] = [],
) {
export default function getNextNDaysTaskQuery(days: number) {
const start = dayjs().format('YYYYMMDD');
const next = dayjs().add(days, 'd').format('YYYYMMDD');
const markers = customMarkers.map((m) => '"' + m + '"').join(' ');

const query = `
[:find (pull ?b [*])
:where
[?b :block/marker ?marker]
[(contains? #{"NOW" "LATER" "TODO" "DOING" ${markers}} ?marker)]
[(contains? #{"NOW" "LATER" "TODO" "DOING"} ?marker)]
[?b :block/page ?p]
(or
[?b :block/scheduled ?d]
Expand Down
13 changes: 7 additions & 6 deletions src/querys/scheduled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ import dayjs, { Dayjs } from 'dayjs';

export default function getScheduledTaskQuery(
startDate: Dayjs | Date = new Date(),
customMarkers: string[] = [],
) {
const start = dayjs(startDate).format('YYYYMMDD');
const markers = customMarkers.map((m) => '"' + m + '"').join(' ');

const query = `
[:find (pull ?b [*])
:where
[?b :block/marker ?marker]
[(contains? #{"NOW" "LATER" "TODO" "DOING" ${markers}} ?marker)]
[(contains? #{"NOW" "LATER" "TODO" "DOING"} ?marker)]
[?b :block/page ?p]
(or
[?b :block/scheduled ?d]
[?b :block/deadline ?d])
(or
[?b :block/scheduled ?d]
[?b :block/deadline ?d])
(and
[?p :block/journal? true]
[?p :block/journal-day ?d]))
[(> ?d ${start})]]
`;

Expand Down

0 comments on commit 035ebac

Please sign in to comment.