packages feed

Villefort 0.1.2.9 → 0.1.2.10

raw patch · 8 files changed

+51/−38 lines, 8 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Villefort.Todo: [pred] :: Row -> Double
+ Villefort.Todo: apply :: [t -> a] -> [t] -> [a]
+ Villefort.Todo: getTime :: (MonadReader VConfig m, MonadIO m) => String -> m Int
- Villefort.Database: clean :: () => a -> a
+ Villefort.Database: clean :: [Char] -> [Char]
- Villefort.Todo: Row :: Int -> String -> String -> String -> String -> Int -> Row
+ Villefort.Todo: Row :: Int -> String -> String -> String -> String -> Int -> Double -> Row
- Villefort.Todo: toRow :: [String] -> Row
+ Villefort.Todo: toRow :: [String] -> Int -> Double -> Row

Files

README.md view
@@ -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 @@ 
 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 @@ 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 @@ 	|-- 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
 
Villefort.cabal view
@@ -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
src/Villefort/Daily.hs view
@@ -72,7 +72,7 @@ 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)
src/Villefort/Database.hs view
@@ -107,5 +107,5 @@ --getSum :: IO (Maybe [String])  -clean = id --replace "'" "''"+clean = replace "'" "''"  
src/Villefort/Log.hs view
@@ -7,7 +7,6 @@ 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 @@  -- | 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
src/Villefort/Server.hs view
@@ -40,7 +40,7 @@   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 @@   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 @@     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 @@     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
src/Villefort/Todo.hs view
@@ -6,7 +6,7 @@ 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 @@                  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 @@ 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 @@   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 @@   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 @@   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 @@   -- | 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)
src/Villefort/Weekly.hs view
@@ -38,13 +38,13 @@   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