Skip to content

Commit 71e4603

Browse files
committed
Add modified command
1 parent 43855ce commit 71e4603

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

tasklite-core/app/Main.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ data Command
115115
| ListNew
116116
| ListOld
117117
| ListOpen
118+
| ListModified
118119
| ListDone
119120
| ListObsolete
120121
| ListDeletable
@@ -462,6 +463,9 @@ commandParser conf =
462463

463464
<> command "open" (toParserInfo (pure ListOpen)
464465
"List all open tasks by priority desc")
466+
467+
<> command "modified" (toParserInfo (pure ListModified)
468+
"List all modified tasks by modified_utc desc")
465469

466470
-- All tasks due to no later than
467471
-- <> command "yesterday"
@@ -853,6 +857,7 @@ executeCLiCommand conf now connection cmd =
853857
ListNew -> newTasks conf now connection
854858
ListOld -> listOldTasks conf now connection
855859
ListOpen -> openTasks conf now connection
860+
ListModified -> modifiedTasks conf now connection
856861
ListOverdue -> overdueTasks conf now connection
857862
ListRepeating -> listRepeating conf now connection
858863
ListRecurring -> listRecurring conf now connection

tasklite-core/source/Lib.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,24 @@ openTasks conf now connection = do
15711571
\order by `priority` desc"
15721572
pure $ formatTasks conf now tasks
15731573

1574+
modifiedTasks :: Config -> DateTime -> Connection -> IO (Doc AnsiStyle)
1575+
modifiedTasks conf now connection = do
1576+
tasks <- query_ connection $ Query
1577+
"select * from `tasks_view` \
1578+
\order by `modified_utc` desc"
1579+
pure $ formatTasks conf now $ filterModified tasks
1580+
where
1581+
filterModified =
1582+
P.filter (\task ->
1583+
(removeNSec $ ulidTextToDateTime $ FullTask.ulid task)
1584+
/= (parseUtc $ FullTask.modified_utc task))
1585+
removeNSec :: Maybe DateTime -> Maybe DateTime
1586+
removeNSec mDateTime =
1587+
case mDateTime of
1588+
Just dateTime -> Just $ dateTime { dtTime = (dtTime dateTime) { todNSec = 0 } }
1589+
Nothing -> Nothing
1590+
1591+
15741592

15751593
overdueTasks :: Config -> DateTime -> Connection -> IO (Doc AnsiStyle)
15761594
overdueTasks conf now connection = do

tasklite-core/tasklite-core.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22

3-
-- This file has been generated from package.yaml by hpack version 0.31.2.
3+
-- This file has been generated from package.yaml by hpack version 0.34.2.
44
--
55
-- see: https://github.com/sol/hpack
66
--

0 commit comments

Comments
 (0)