summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChrisReuter <>2018-03-04 19:21:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-03-04 19:21:00 (GMT)
commit8918df33e4a8c07aefd7f9ee53721bb448501ca0 (patch)
treeaa4a5b0872d48e463eab151adbe71a0f0346f350
parent85392e5654a62778eac819460439f8586263c2a2 (diff)
version 0.1.2.100.1.2.10
-rw-r--r--README.md18
-rw-r--r--Villefort.cabal4
-rw-r--r--src/Villefort/Daily.hs2
-rw-r--r--src/Villefort/Database.hs2
-rw-r--r--src/Villefort/Log.hs8
-rw-r--r--src/Villefort/Server.hs9
-rw-r--r--src/Villefort/Todo.hs36
-rw-r--r--src/Villefort/Weekly.hs10
8 files changed, 51 insertions, 38 deletions
diff --git a/README.md b/README.md
index 593bb46..ca47d7c 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
# Villefort
Villefort is a time managment system written in Haskell.
-## Version 1.2.9
-- Fixed corrupted database which will make 1.2.8, 1.2.7 and 1.2.6 not work.
-- Fixed bug in Weekly page date handling.
+## Version 1.2.10
+- Fixed bug in collecting the time spent on project.
+- Removed unecessary print statements.
[default config](https://github.com/Chrisr850/Villefort/blob/master/src/Villefort/Config.hs)
@@ -35,11 +35,11 @@ import System.IO.Strict as S
main :: IO ()
main = villefort def {
- daily = [calendar ],
+ daily = [xcalendar ],
weekly = defWeekly {
- monday = [push],
- wednesday = [push],
- friday = [push,
+ monday = [moref],
+ wednesday = [more],
+ friday = [more,
scan]
},
@@ -50,7 +50,7 @@ calendar = pure ["","check calendar","admin"]
scan = pure ["scan class notes","scan","admin"]
path = "/home/chris/.villefort/push"
-push = do
+more = do
z <- S.readFile path -- readfile to get # push ups
let num = read z :: Double
writeFile path (show (num+0.3))
@@ -93,7 +93,7 @@ Villefort-0.1.1.1/
|-- js.js
```
Just copy the data/todo.db from the old version into data/todo.db of the new version.
-Remember to rebuild Villefort if you have a custom build to rebuild with the new villefort.
+Remember to rebuild Villefort if you have a custom build to rebuild with the new version.
Villefort --recompile
diff --git a/Villefort.cabal b/Villefort.cabal
index 2cebb0a..6a60352 100644
--- a/Villefort.cabal
+++ b/Villefort.cabal
@@ -1,7 +1,7 @@
name: Villefort
-version: 0.1.2.9
+version: 0.1.2.10
synopsis: Villefort is a task manager and time tracker written in haskell.
-description: Villefort is a browser based time tracker.
+description: Villefort is a browser based time tracker. It offers the creation of weekly and daily triggered tasks. It also offers stats on both daily, weekly and total time spent on tasks.
homepage: https://github.com/Chrisr850/Villefort#readme
license: BSD3
license-file: LICENSE
diff --git a/src/Villefort/Daily.hs b/src/Villefort/Daily.hs
index e6a0bb5..21c4702 100644
--- a/src/Villefort/Daily.hs
+++ b/src/Villefort/Daily.hs
@@ -72,7 +72,7 @@ checkYear oldDate currentDate = (year oldDate) == (year currentDate)
runDaily :: VConfig -> D -> D -> IO ()
runDaily vconf oldDate currentDate=
if (checkDay oldDate currentDate) then
- putStrLn "same-day"
+ return ()
else
putStrLn "adding-daily" >> do
dailies <- sequence (daily vconf)
diff --git a/src/Villefort/Database.hs b/src/Villefort/Database.hs
index 5c030eb..6b0cbdc 100644
--- a/src/Villefort/Database.hs
+++ b/src/Villefort/Database.hs
@@ -107,5 +107,5 @@ getDone = makeQuery "select Title, time from todo where substr(Due,1,10) = Dat
--getSum :: IO (Maybe [String])
-clean = id --replace "'" "''"
+clean = replace "'" "''"
diff --git a/src/Villefort/Log.hs b/src/Villefort/Log.hs
index 106289b..87c8d9d 100644
--- a/src/Villefort/Log.hs
+++ b/src/Villefort/Log.hs
@@ -7,7 +7,6 @@ import Villefort.Database
import Villefort.Util
import Paths_Villefort
import System.Random
-import Data.String.Utils (replace)
-- | Generate stats
genStats :: (MonadReader VConfig m, MonadIO m) => m String
@@ -36,10 +35,9 @@ table = " <script src='templates/js.js'></script><h1> avg </h1>"
-- | creates the github like graph from database
---makeGithub ::(MonadReader VConfig m, MonadIO m) => String -> m Subject
-makeGithub subject1 = do
- let subject = replace "'" "&#39;" subject1
- z <- makeQuery ("select substr(Due,1,10) from todo where subject = \"" ++ (clean subject) ++ "\" and state = 0 and time!= 0")
+makeGithub ::(MonadReader VConfig m, MonadIO m) => String -> m Subject
+makeGithub subject = do
+ z <- makeQuery ("select substr(Due,1,10) from todo where subject = '" ++ (clean subject) ++ "' and state = 0")
color <- liftIO $ getColor
let header = "<h2 id='"++ subject ++ "'> Calendar "++ subject ++ " </h2> <script> new Calendar({ append_to: '" ++ subject ++ "',num_weeks: 51,day_size: 11, data: ["
let q = Prelude.map (\x -> "['" ++ (x !! 0) ++"',500],") z
diff --git a/src/Villefort/Server.hs b/src/Villefort/Server.hs
index 02cd2d4..303cd1d 100644
--- a/src/Villefort/Server.hs
+++ b/src/Villefort/Server.hs
@@ -40,7 +40,7 @@ villefort conf = do
case args of
["--custom",_] -> putStrLn "custom" >> launch conf
["--recompile"] -> putStrLn "recompiling" >> recompile
- _ -> do
+ _ -> putStrLn "straight starting " >> do
if noCustom conf
then launch conf >> putStrLn "overload"
else checkCustomBuild >> launch conf
@@ -65,8 +65,8 @@ checkCustomBuild = do
isBuild <- doesFileExist path
dataDir <- getDataDir
if isBuild
- then putStrLn "custom build detected" >> executeFile path True ["--custom",dataDir] Nothing
- else putStrLn "no custom build found"
+ then putStrLn "custom buil detected" >> executeFile path True ["--custom",dataDir] Nothing
+ else putStrLn "no custom build :("
-- | actually launches the scotty server
launch :: VConfig -> IO ()
@@ -89,11 +89,9 @@ launch conf = do
post "/update" $ do
rawHtml <- body
let da = Data.List.Split.splitOn "&" (show rawHtml)
- do liftIO $ print $ show da
let rawid = Data.List.Split.splitOn "=" $ (Prelude.init (da !! 1))
let sqlId = read (rawid!! 1) :: Int
let rawtime = Data.List.Split.splitOn "=" $ (da !! 0)
- do liftIO $ print rawtime
let insertTime = read (rawtime !! 1) :: Int
liftIO $ runReaderT (updateTodos sqlId insertTime) conf
redirect "/"
@@ -101,7 +99,6 @@ launch conf = do
post "/add" $ do
rawBody <-body
let parse = Data.List.Split.splitOn "&" (show rawBody)
- do liftIO $ print parse
-- !@#$%^&*()_+
let rep = replace "+" " " . replace "%21" "!" . replace "%40" "@" . replace "%23" "#" . replace "%24" "$" . replace "%25" "%" . replace "%5E" "^" . replace "%26" "&" . replace "%28" "(" . replace "%29" ")" . replace "%2B" "+"
let summary = rep $ getIndex parse 0
diff --git a/src/Villefort/Todo.hs b/src/Villefort/Todo.hs
index a077f2c..fc8b096 100644
--- a/src/Villefort/Todo.hs
+++ b/src/Villefort/Todo.hs
@@ -6,7 +6,7 @@ import Villefort.Database
import Villefort.Util
import Control.Monad.IO.Class
import Data.List.Split
-import Data.ByteString.Lazy hiding (map,length,take,readFile,zip)
+import Data.ByteString.Lazy hiding (map,length,take,readFile,zip,head)
import Paths_Villefort
import Database.HDBC
import Control.Monad.Reader
@@ -29,11 +29,12 @@ data Row = Row { rid :: Int,
description :: String,
due :: String,
subject :: String,
- time :: Int
+ time :: Int,
+ pred :: Double
} deriving (Show,Eq)
-toRow :: [String] -> Row
-toRow x = Row (read (x !! 0) :: Int) (x !! 1) (x !! 2) (x !! 3) ( x !! 4) (read ( x !! 5) :: Int)
+toRow :: [String] -> Int -> Double -> Row
+toRow x = Row (read (x !! 0) :: Int) (x !! 1) (x !! 2) (x !! 3)( x !! 4)
updateTodos :: (MonadReader VConfig m, MonadIO m) => Int -> Int -> m ()
updateTodos sqlId timeTaken = execQuery "insert into todo (id,Description,Title,Entered,Due,state,time,Subject) select id,Description,Title,Entered,datetime('now', 'localtime'),0,?,Subject from todo where id = ? limit 1" [ timeTaken, sqlId]
@@ -41,11 +42,27 @@ updateTodos sqlId timeTaken = execQuery "insert into todo (id,Description,Title,
delTask :: (MonadReader VConfig m, MonadIO m) => Int -> m ()
delTask sqlId = execQuery "update todo set state = 0 where id = ?" [sqlId]
+-- | returns time spent on task based off of Task id
+getTime :: (MonadReader VConfig m,MonadIO m) => String -> m Int
+getTime id = do
+ idval <- makeQuery' $ "select sum(time) from todo where id = " ++ show id
+ pure $ (read ((idval !! 0) !! 0) :: Int)
+
+-- | returns Row data structures for each open task
qetTasks' :: (MonadReader VConfig m, MonadIO m) => m [Row]
qetTasks' = do
- x <- makeQuery' "select id, Title, Description, Due, Subject, sum(time), pred from todo where state=1 group by id order by Due"
- return (map toRow x)
+ x <- makeQuery' "select id, Title, Description, Due, Subject, pred from todo where state=1 group by id order by Due"
+ let ids = map head x
+ times <- mapM getTime ids
+ let halfRows = (map toRow x) :: [Int -> Double -> Row]
+ let z = apply halfRows times
+ return $ apply z [0,0 .. 1]
+-- | applies a list of functions to a list of values
+apply :: [t -> a] -> [t] -> [a]
+apply (x:xs) (y:ys) = [x y] ++ apply xs ys
+apply [] (_:_) = []
+apply [] []= []
convRow' :: [[SqlValue]] -> [[String]]
convRow' dat = Prelude.map (\x -> Prelude.map (\y -> conv' y ) x) dat
@@ -57,6 +74,7 @@ conv' x = case fromSql x of
Nothing -> "0"
--makeQuery :: Query -> IO [[String]]
+-- |makes Query
makeQuery' :: (MonadReader VConfig m, MonadIO m) => String -> m [[String]]
makeQuery' query = do
conn <- getDb
@@ -64,12 +82,12 @@ makeQuery' query = do
liftIO $ disconnect conn
return (convRow' taskRaw)
-
+-- | merges two lists
merge :: [a] -> [a] -> [a]
merge [] ys = ys
merge (x:xs) ys = x:merge ys xs
-
+-- | generates modal for task based of Row data Structure
genModal' :: Row -> IO String
genModal' row = if rid row == 1 then return (" ") else do
let f = due row
@@ -133,6 +151,7 @@ getTodos = do
let body = Prelude.concat modals
return (header ++ theme ++ body)
+-- | support for user defined themes in villefort config
getTheme :: (MonadReader VConfig m, MonadIO m) => m String
getTheme = do
userConfig <- ask
@@ -144,7 +163,6 @@ getTheme = do
-- | Delete a done task from database sets state = 0 but it's record is still maintained in the database for the stats page.
-
deleteTodo :: (MonadReader VConfig m, MonadIO m) => ByteString -> m ()
deleteTodo raw = do
let da = Data.List.Split.splitOn "&" (show raw)
diff --git a/src/Villefort/Weekly.hs b/src/Villefort/Weekly.hs
index 66a623b..179ab65 100644
--- a/src/Villefort/Weekly.hs
+++ b/src/Villefort/Weekly.hs
@@ -38,13 +38,13 @@ getStartOfWeek = do
return $ addDays (-currentDay) today
fromZonedTimeToDay :: String -> Day
-fromZonedTimeToDay x = fromGregorian ( y split 0) (md split 1) (md split 2)
+fromZonedTimeToDay x = fromGregorian (read (split !! 0) :: Integer) (read (split !! 1) :: Int) (read (take 2 (split !! 2)) :: Int)
where split = S.splitOn "-" x
- md splits x = read (take 2 $ splits !! x) :: Int
- y splits x = read ( splits !! x ) :: Integer
-
getDate :: IO Day
-getDate = fromZonedTimeToDay <$> show <$> getZonedTime
+getDate = do
+ a <- getZonedTime
+ let z = show a
+ return $ fromZonedTimeToDay z
getDay :: IO Int
getDay = do