This commit is contained in:
+9
-7
@@ -105,15 +105,17 @@ insertEntry conn filename day mComment = do
|
|||||||
fromMaybe d Nothing = d
|
fromMaybe d Nothing = d
|
||||||
fromMaybe _ (Just x) = x
|
fromMaybe _ (Just x) = x
|
||||||
|
|
||||||
-- | Fetch all entries for a given recipe, newest first.
|
{- | Fetch all entries for a given recipe, newest first.
|
||||||
-- Tries both the normalized key and with @.cook@ appended (for legacy entries).
|
Tries both the normalized key and with @.cook@ appended (for legacy entries).
|
||||||
|
-}
|
||||||
fetchEntries :: Connection -> Text -> IO [CookEntry]
|
fetchEntries :: Connection -> Text -> IO [CookEntry]
|
||||||
fetchEntries conn filename = do
|
fetchEntries conn filename = do
|
||||||
entries <- SQL.query
|
entries <-
|
||||||
conn
|
SQL.query
|
||||||
"SELECT id, recipe_filename, cooked_date, comment, created_at \
|
conn
|
||||||
\ FROM cook_log WHERE recipe_filename = ? ORDER BY cooked_date DESC, id DESC"
|
"SELECT id, recipe_filename, cooked_date, comment, created_at \
|
||||||
(Only filename)
|
\ FROM cook_log WHERE recipe_filename = ? ORDER BY cooked_date DESC, id DESC"
|
||||||
|
(Only filename)
|
||||||
if null entries
|
if null entries
|
||||||
then
|
then
|
||||||
SQL.query
|
SQL.query
|
||||||
|
|||||||
+1
-1
@@ -21,9 +21,9 @@ import qualified Data.ByteString.Lazy as LB
|
|||||||
import Data.Char (digitToInt, isAlphaNum, toLower)
|
import Data.Char (digitToInt, isAlphaNum, toLower)
|
||||||
import Data.IORef (IORef, atomicModifyIORef', newIORef, readIORef, writeIORef)
|
import Data.IORef (IORef, atomicModifyIORef', newIORef, readIORef, writeIORef)
|
||||||
import Data.List (isSuffixOf, sortOn)
|
import Data.List (isSuffixOf, sortOn)
|
||||||
import Data.Ord (Down (Down))
|
|
||||||
import Data.Map.Strict (Map)
|
import Data.Map.Strict (Map)
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
|
import Data.Ord (Down (Down))
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Data.Text.Encoding (encodeUtf8)
|
import Data.Text.Encoding (encodeUtf8)
|
||||||
|
|||||||
Reference in New Issue
Block a user