summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChrisReuter <>2018-05-31 14:38:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-05-31 14:38:00 (GMT)
commit5f89e2ab49b35ac41c6ded441740c15887619eac (patch)
tree7e092d0a934e4b8ddeb03fce25282dd7bfcab864
parent8918df33e4a8c07aefd7f9ee53721bb448501ca0 (diff)
version 0.1.2.110.1.2.11
-rw-r--r--Main.hs2
-rw-r--r--README.md5
-rw-r--r--Villefort.cabal10
-rw-r--r--data/date1
-rw-r--r--data/day1
-rw-r--r--data/todo.dbbin122880 -> 122880 bytes
-rw-r--r--src/Villefort/Daily.hs38
-rw-r--r--src/Villefort/Database.hs2
-rw-r--r--src/Villefort/Log.hs2
-rw-r--r--src/Villefort/Server.hs4
-rw-r--r--src/Villefort/Todo.hs3
-rw-r--r--src/Villefort/Weekly.hs12
-rw-r--r--templates/modal.ts1
13 files changed, 47 insertions, 34 deletions
diff --git a/Main.hs b/Main.hs
index 21d2d3b..df1c2d0 100644
--- a/Main.hs
+++ b/Main.hs
@@ -5,4 +5,4 @@ import Villefort.Definitions
import Villefort.Config
main :: IO ()
-main = villefort def
+main = villefort def
diff --git a/README.md b/README.md
index ca47d7c..52dae3b 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,8 @@
# Villefort
Villefort is a time managment system written in Haskell.
-## Version 1.2.10
-- Fixed bug in collecting the time spent on project.
-- Removed unecessary print statements.
+## Version 1.2.11
+- Integrated date and day tracking into database to stop file corruption.
[default config](https://github.com/Chrisr850/Villefort/blob/master/src/Villefort/Config.hs)
diff --git a/Villefort.cabal b/Villefort.cabal
index 6a60352..87072cf 100644
--- a/Villefort.cabal
+++ b/Villefort.cabal
@@ -1,7 +1,7 @@
name: Villefort
-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. It offers the creation of weekly and daily triggered tasks. It also offers stats on both daily, weekly and total time spent on tasks.
+version: 0.1.2.11
+synopsis: Villefort is a task manager and time tracker
+description: Villefort is a browser based time tracker built around a sqlite3 database.
homepage: https://github.com/Chrisr850/Villefort#readme
license: BSD3
license-file: LICENSE
@@ -13,9 +13,7 @@ build-type: Simple
extra-source-files: README.md
cabal-version: >=1.10
-data-files: data/date
- , data/todo.db
- , data/day
+data-files: data/todo.db
, templates/*.html
, templates/*.ts
, templates/header
diff --git a/data/date b/data/date
deleted file mode 100644
index 8dbb657..0000000
--- a/data/date
+++ /dev/null
@@ -1 +0,0 @@
-2018-01-03 \ No newline at end of file
diff --git a/data/day b/data/day
deleted file mode 100644
index e440e5c..0000000
--- a/data/day
+++ /dev/null
@@ -1 +0,0 @@
-3 \ No newline at end of file
diff --git a/data/todo.db b/data/todo.db
index cb480ae..abad9b0 100644
--- a/data/todo.db
+++ b/data/todo.db
Binary files differ
diff --git a/src/Villefort/Daily.hs b/src/Villefort/Daily.hs
index 21c4702..571108c 100644
--- a/src/Villefort/Daily.hs
+++ b/src/Villefort/Daily.hs
@@ -36,30 +36,42 @@ getDay = do
z <- getDate
return $ snd $mondayStartWeek z
+
+writeDate :: (MonadReader VConfig m, MonadIO m) => m ()
+writeDate = do
+ date <- liftIO $ show <$> getDate
+ execQuery ("update dates set date = ? where type = 'date';") [date]
+
+readDate :: (MonadReader VConfig m, MonadIO m) => m D
+readDate = do
+ rawDate <- makeQuery "select date from dates where type = 'date';"
+ return $ unpackStringToDate $ head $ head $ rawDate
+
+{-
writeDate :: IO ()
writeDate = do
date <- show <$> getDate
datePath <- getDataFileName "data/date"
writeFile datePath date
+
readDate :: IO D
readDate = do
datePath <- getDataFileName "data/date"
rawDate <- S.readFile datePath
let date = unpackStringToDate rawDate
return date
+-}
-writeDay :: IO ()
+writeDay :: (MonadReader VConfig m, MonadIO m) => m ()
writeDay = do
- newDay <- show <$> getDay
- datePath <- getDataFileName "data/day"
- writeFile datePath newDay
-
-readDay :: IO Int
+ newDay <- liftIO $ show <$> getDay
+ execQuery ("update dates set date = ? where type = 'day';") [newDay]
+
+readDay :: (MonadReader VConfig m, MonadIO m) => m Int
readDay = do
- datePath <- getDataFileName "data/day"
- rawDay <- S.readFile datePath
- let int = read rawDay :: Int
+ rawDay <- makeQuery "select date from dates where type = 'day';"
+ let int = read (head $ head $ rawDay) :: Int
return int
checkDay :: D -> D ->Bool
@@ -120,14 +132,14 @@ selector conf x
--man :: IO ()
man :: VConfig -> IO ()
man conf = do
- oldDate <- readDate
+ oldDate <- runReaderT readDate conf
currentDate <- getDateD
- oldDay <- readDay
+ oldDay <- runReaderT readDay conf
currentDay <- getDay
runWeekly conf oldDay currentDay
runDaily conf oldDate currentDate
- writeDate
- writeDay
+ runReaderT writeDate conf
+ runReaderT writeDay conf
threadDelay 18000000
dailyCheck :: VConfig -> IO b
diff --git a/src/Villefort/Database.hs b/src/Villefort/Database.hs
index 6b0cbdc..5c030eb 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 = replace "'" "''"
+clean = id --replace "'" "''"
diff --git a/src/Villefort/Log.hs b/src/Villefort/Log.hs
index 87c8d9d..9060176 100644
--- a/src/Villefort/Log.hs
+++ b/src/Villefort/Log.hs
@@ -35,7 +35,7 @@ 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 ::(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
diff --git a/src/Villefort/Server.hs b/src/Villefort/Server.hs
index 303cd1d..ad5c608 100644
--- a/src/Villefort/Server.hs
+++ b/src/Villefort/Server.hs
@@ -61,7 +61,6 @@ checkCustomBuild :: IO ()
checkCustomBuild = do
dir <- getAppUserDataDirectory "villefort"
let path = dir ++ "/villefort"
- putStrLn path
isBuild <- doesFileExist path
dataDir <- getDataDir
if isBuild
@@ -89,9 +88,11 @@ 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 "/"
@@ -99,6 +100,7 @@ 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 fc8b096..b2addbd 100644
--- a/src/Villefort/Todo.hs
+++ b/src/Villefort/Todo.hs
@@ -55,7 +55,9 @@ qetTasks' = do
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
+ liftIO $ print $ length times
let halfRows = (map toRow x) :: [Int -> Double -> Row]
+ liftIO $ print $ length halfRows
let z = apply halfRows times
return $ apply z [0,0 .. 1]
-- | applies a list of functions to a list of values
@@ -100,6 +102,7 @@ genModal' row = if rid row == 1 then return (" ") else do
title row,
description row,
show $ time row,
+ show $ Villefort.Todo.pred row,
"/delete",
show $ rid row
]
diff --git a/src/Villefort/Weekly.hs b/src/Villefort/Weekly.hs
index 179ab65..9908da4 100644
--- a/src/Villefort/Weekly.hs
+++ b/src/Villefort/Weekly.hs
@@ -1,5 +1,5 @@
{-# LANGUAGE FlexibleContexts #-}
-module Villefort.Weekly where
+module Villefort.Weekly (weeklyStats) where
import Control.Monad.Reader
import Villefort.Definitions
@@ -38,13 +38,13 @@ getStartOfWeek = do
return $ addDays (-currentDay) today
fromZonedTimeToDay :: String -> Day
-fromZonedTimeToDay x = fromGregorian (read (split !! 0) :: Integer) (read (split !! 1) :: Int) (read (take 2 (split !! 2)) :: Int)
+fromZonedTimeToDay x = fromGregorian ( y split 0) (md split 1) (md split 2)
where split = S.splitOn "-" x
+ md splits x = read ( splits !! x) :: Int
+ y splits x = read ( splits !! x ) :: Integer
+
getDate :: IO Day
-getDate = do
- a <- getZonedTime
- let z = show a
- return $ fromZonedTimeToDay z
+getDate = fromZonedTimeToDay <$> show <$> getZonedTime
getDay :: IO Int
getDay = do
diff --git a/templates/modal.ts b/templates/modal.ts
index f5414f8..f186271 100644
--- a/templates/modal.ts
+++ b/templates/modal.ts
@@ -15,6 +15,7 @@
<p> } </p>
<p> Total minutes spent working on Project } </p>
+ <p> Predicted time } </p>
</div>
<div class="modal-footer">
<form class="pull-left" action="}" method="post" class="add-entry">