diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2018-03-12 14:15:57 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2018-03-12 14:17:28 +0100 |
commit | 9c921f99adbd4637b21507e15c93a06c4909898a (patch) | |
tree | c9f21985b3e6f6e5ca7fbf45432d594e922e2303 /src/Db.hs | |
parent | 658b5e01c9f792be73fd984664da923d3e5ce38d (diff) | |
download | comatose-9c921f99adbd4637b21507e15c93a06c4909898a.tar.gz comatose-9c921f99adbd4637b21507e15c93a06c4909898a.tar.bz2 comatose-9c921f99adbd4637b21507e15c93a06c4909898a.zip |
Prepare for publication
Add a few more protocols, process BibTeX files with biber, copy&paste
whitepaper, add proper license.
Diffstat (limited to 'src/Db.hs')
-rw-r--r-- | src/Db.hs | 34 |
1 files changed, 32 insertions, 2 deletions
@@ -1,3 +1,25 @@ +{- +Copyright 2015–2018 comatose contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +-} + {-# LANGUAGE OverloadedStrings #-} module Db where @@ -103,13 +125,21 @@ split delim s = let (a, b:bs) = span (/= delim) s in a:split delim bs getFeatureBase :: String -> String getFeatureBase feature = head $ split '.' feature +-- |Get all publication years for all protocols publicationYears :: Database -> [Int] -publicationYears db = map read $ catMaybes $ map (lookup "year" . E.fields) $ dpublications db +publicationYears db = catMaybes $ map publicationYear $ dpublications db + +-- |Get earliest year for one publication +publicationYear :: E.T -> Maybe Int +publicationYear e = (lookup "date" $ E.fields e) >>= return . extractYear + where + -- simple iso year extraction + extractYear = read . takeWhile (/= '-') -- |Get number of publications by year publicationYearHist :: Database -> [(Int, Int)] publicationYearHist db = map (\(x:xs) -> (x, length (x:xs))) $ group years - where years = sort $ publicationYears db + where years = sort $ publicationYears db minMaxPublicationYears db = (firstyear, lastyear) where |