casr-logbook 0.6.6 → 0.6.7
raw patch · 7 files changed
+205/−85 lines, 7 files
Files
- casr-logbook.cabal +1/−1
- changelog +4/−0
- src/Data/Aviation/Casr/Logbook/Html/Html.hs +40/−2
- src/Data/Aviation/Casr/Logbook/Reports/FlightTimeReport.hs +93/−58
- src/Data/Aviation/Casr/Logbook/Reports/Html.hs +29/−20
- src/Data/Aviation/Casr/Logbook/Types/AircraftFlight.hs +19/−4
- src/Data/Aviation/Casr/Logbook/Types/Command.hs +19/−0
casr-logbook.cabal view
@@ -1,5 +1,5 @@ name: casr-logbook-version: 0.6.6+version: 0.6.7 license: OtherLicense license-file: LICENSE author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ>
changelog view
@@ -1,3 +1,7 @@+0.6.7++* Add solo approval+ 0.6.6 * Semigroup/Monoid for AircraftFlightMeta
src/Data/Aviation/Casr/Logbook/Html/Html.hs view
@@ -51,6 +51,40 @@ import Control.Lens import Control.Monad(when, (=<<), (>>=)) import Data.Aviation.Casr.Logbook.Types+ ( Location(Location),+ Engine(..),+ Time(Time),+ TimeAmount(TimeAmount),+ HasTime(daytime),+ zerotimeamount,+ Rating(Rating),+ Aircraft(Aircraft),+ FlightPoint(FlightPoint),+ Aviator(Aviator),+ HasAircraft(aircraftRegistration),+ DayNight(DayNight),+ HasFlightPoint(point, landingTime),+ HasAviator(arn, surname, firstname),+ FlightPath,+ HasFlightPath(flightEnd, flightStart),+ flightPathList,+ Command(..),+ SimulatorFlight(SimulatorFlight),+ Briefing(Briefing),+ Exam(Exam),+ HasExam(examTime, examName),+ HasSimulatorFlight(simulatortype, simulatorflightname),+ HasBriefing(briefingTime, briefingName),+ AircraftFlight(AircraftFlight),+ HasAircraftFlight(flightpath, flightaircraft, aircraftflightname),+ Entry(..),+ Entries(..),+ Logbook(Logbook),+ HasLogbook(logbookaviator),+ Instruction,+ HasInstructionRating(instructionRating),+ HasInstructionLesson(lesson, student, instructionLesson),+ shortStringRating ) import Data.Bool(not) import Data.Char(toUpper) import Data.Digit(DecDigit, charDecimal)@@ -176,8 +210,8 @@ do span_ [class_ "key"] "Name: " span_ [class_ "value"] $ do fromString (toUpper <$> s)- ", "- fromString f+ when (not . null $ f) $+ toHtmlRaw (", " <> f) htmlAviatorARN :: [DecDigit]@@ -279,6 +313,10 @@ span_ [class_ "commandaviator"] $ htmlAviatorShort a htmlCommand _ (Dual a) = do span_ [class_ "command dualunderinstruction"] "Dual Under-Instruction"+ span_ [class_ "commandphrase"] " by "+ span_ [class_ "commandaviator"] $ htmlAviatorShort a+htmlCommand _ (ApprovedSolo a) =+ do span_ [class_ "command approvedsolo"] "Approved Solo" span_ [class_ "commandphrase"] " by " span_ [class_ "commandaviator"] $ htmlAviatorShort a
src/Data/Aviation/Casr/Logbook/Reports/FlightTimeReport.hs view
@@ -8,24 +8,28 @@ ) where import Control.Category((.))-import Control.Lens ( (^.), view, makeClassy )+import Control.Lens ( preview, (^.), view, isn't, makeClassy ) import Data.Aviation.Casr.Logbook.Types- ( Engine(Multi, Single),- TimeAmount,+ ( TimeAmount,+ AsEngine(_Multi, _Single), Aviator, HasAircraft(aircraftRegistration, aircraftType, aircraftEngine), HasDayNight(nightDayNight, dayDayNight), totalDayNight,- Command(InCommandInstructing, InCommand, Dual, ICUS),- HasAircraftFlight(instrumentflightTime, flightaircraft, command,- daynight),+ AsCommand(_InCommandInstructing, _InCommand, _Dual, _ICUS),+ HasAircraftFlight(instrumentflightTime, daynight, flightaircraft,+ command), Entry(AircraftFlightEntry), Entries(Entries), Logbook(Logbook), HasInstructionRating(instructionRating),+ AsInstructionRating(_GA3InstructionRating, _GA2InstructionRating,+ _GA1InstructionRating, _RASIInstructionRating,+ _RAInstructionRating), getUnderInstructionPic, isRAInstruction,- isGAInstruction )+ isGAInstruction,+ aeronauticalHours ) import Data.Eq(Eq) import Data.Foldable(foldl') import Data.Int(Int)@@ -82,8 +86,18 @@ TimeAmount , _hoursGAInstructing :: TimeAmount+ , _hoursGA1Instructing ::+ TimeAmount+ , _hoursGA2Instructing ::+ TimeAmount+ , _hoursGA3Instructing ::+ TimeAmount , _hoursRAInstructing :: TimeAmount+ , _hoursRAJuniorInstructing ::+ TimeAmount+ , _hoursRASeniorInstructing ::+ TimeAmount , _hoursNight :: TimeAmount , _hoursNightICUS ::@@ -101,7 +115,7 @@ makeClassy ''FlightTimeReport instance Semigroup FlightTimeReport where- FlightTimeReport ft1 tl1 tli1 tld1 tlc1 tp1 rg1 se1 sei1 sed1 sec1 me1 mei1 med1 mec1 dy1 dyi1 dyd1 dyc1 ins1 insg1 insr1 nt1 nti1 ntd1 ntc1 wpc1 is1 <> FlightTimeReport ft2 tl2 tli2 tld2 tlc2 tp2 rg2 se2 sei2 sed2 sec2 me2 mei2 med2 mec2 dy2 dyi2 dyd2 dyc2 ins2 insg2 insr2 nt2 nti2 ntd2 ntc2 wpc2 is2 =+ FlightTimeReport ft1 tl1 tli1 tld1 tlc1 tp1 rg1 se1 sei1 sed1 sec1 me1 mei1 med1 mec1 dy1 dyi1 dyd1 dyc1 ins1 insg1 insg1_1 insg1_2 insg1_3 insr1 insr1_j insr1_s nt1 nti1 ntd1 ntc1 wpc1 is1 <> FlightTimeReport ft2 tl2 tli2 tld2 tlc2 tp2 rg2 se2 sei2 sed2 sec2 me2 mei2 med2 mec2 dy2 dyi2 dyd2 dyc2 ins2 insg2 insg2_1 insg2_2 insg2_3 insr2 insr2_j insr2_s nt2 nti2 ntd2 ntc2 wpc2 is2 = FlightTimeReport (ft1 + ft2) (tl1 <> tl2)@@ -124,7 +138,12 @@ (dyc1 <> dyc2) (ins1 <> ins2) (insg1 <> insg2)+ (insg1_1 <> insg2_1)+ (insg1_2 <> insg2_2)+ (insg1_3 <> insg2_3) (insr1 <> insr2)+ (insr1_j <> insr2_j)+ (insr1_s <> insr2_s) (nt1 <> nt2) (nti1 <> nti2) (ntd1 <> ntd2)@@ -163,6 +182,11 @@ mempty mempty mempty+ mempty+ mempty+ mempty+ mempty+ mempty mappend = (<>) @@ -170,81 +194,87 @@ Entry a b c d -> FlightTimeReport singleFlightTimeReport (AircraftFlightEntry fl _) =- let hoursdaynight = totalDayNight (fl ^. daynight)+ let hoursdaynight = totalDayNight (aeronauticalHours fl) icus x =- case fl ^. command of- ICUS _ ->+ case preview (command . _ICUS) fl of+ Just _ -> x- Dual _ ->- mempty- InCommand ->- mempty- InCommandInstructing _ ->+ Nothing -> mempty dual x =- case fl ^. command of- ICUS _ ->- mempty- Dual _ ->+ case preview (command . _Dual) fl of+ Just _ -> x- InCommand ->- mempty- InCommandInstructing _ ->+ Nothing -> mempty comd x =- case fl ^. command of- ICUS _ ->- mempty- Dual _ ->- mempty- InCommand ->+ case preview (command . _InCommand) fl of+ Just _ -> x- InCommandInstructing _ ->+ Nothing -> mempty instr x =- case fl ^. command of- ICUS _ ->- mempty- Dual _ ->- mempty- InCommand ->- mempty- InCommandInstructing _ ->+ case preview (command . _InCommandInstructing) fl of+ Just _ -> x+ Nothing ->+ mempty instrRA x =- case fl ^. command of- ICUS _ ->+ case preview (command . _InCommandInstructing) fl of+ Just a ->+ if isRAInstruction (view instructionRating a) then x else mempty+ Nothing -> mempty- Dual _ ->+ instrGA x =+ case preview (command . _InCommandInstructing) fl of+ Just a ->+ if isGAInstruction (view instructionRating a) then x else mempty+ Nothing -> mempty- InCommand ->+ instrRAJunior x =+ case preview (command . _InCommandInstructing) fl of+ Just a ->+ if isn't _RAInstructionRating (view instructionRating a) then mempty else x+ Nothing -> mempty- InCommandInstructing a ->- if isRAInstruction (view instructionRating a) then x else mempty- instrGA x =- case fl ^. command of- ICUS _ ->+ instrRASenior x =+ case preview (command . _InCommandInstructing) fl of+ Just a ->+ if isn't _RASIInstructionRating (view instructionRating a) then mempty else x+ Nothing -> mempty- Dual _ ->+ instrGA1 x =+ case preview (command . _InCommandInstructing) fl of+ Just a ->+ if isn't _GA1InstructionRating (view instructionRating a) then mempty else x+ Nothing -> mempty- InCommand ->+ instrGA2 x =+ case preview (command . _InCommandInstructing) fl of+ Just a ->+ if isn't _GA2InstructionRating (view instructionRating a) then mempty else x+ Nothing -> mempty- InCommandInstructing a ->- if isGAInstruction (view instructionRating a) then x else mempty+ instrGA3 x =+ case preview (command . _InCommandInstructing) fl of+ Just a ->+ if isn't _GA3InstructionRating (view instructionRating a) then mempty else x+ Nothing ->+ mempty hoursmap k = Map.singleton k (hoursdaynight, icus hoursdaynight, dual hoursdaynight, comd hoursdaynight) singleengine x =- case fl ^. flightaircraft . aircraftEngine of- Single ->+ case preview (flightaircraft . aircraftEngine . _Single) fl of+ Just _ -> x- Multi ->+ Nothing -> mempty multiengine x =- case fl ^. flightaircraft . aircraftEngine of- Single ->- mempty- Multi ->+ case preview (flightaircraft . aircraftEngine . _Multi) fl of+ Just _ -> x+ Nothing ->+ mempty totalhoursday = fl ^. daynight . dayDayNight totalhoursnight =@@ -277,7 +307,12 @@ (comd hoursdaynight) (instr hoursdaynight) (instrGA hoursdaynight)+ (instrGA1 hoursdaynight)+ (instrGA2 hoursdaynight)+ (instrGA3 hoursdaynight) (instrRA hoursdaynight)+ (instrRAJunior hoursdaynight)+ (instrRASenior hoursdaynight) totalhoursnight (icus totalhoursnight) (dual totalhoursnight)
src/Data/Aviation/Casr/Logbook/Reports/Html.hs view
@@ -29,23 +29,6 @@ , htmlAviatorShort ) import Data.Aviation.Casr.Logbook.Reports- ( TakeOffLanding90(TakeOffLanding90),- SimulatorTimeReport,- FlightTimeReport,- HasSimulatorTimeReport(hoursTotalSimulator,- hoursInstrumentSimulator),- HasTakeOffLanding90(currency90, landing3, landing2, landing1,- takeoff3, takeoff2, takeoff1),- HasFlightTimeReport(hoursInstrument, hoursWithPiC,- hoursGAInstructing, hoursRAInstructing, hoursInstructing,- hoursNightInCommand, hoursNightDual, hoursNightICUS, hoursNight,- hoursDayInCommand, hoursDayDual, hoursDayICUS, hoursDay,- hoursMultiEngineInCommand, hoursMultiEngineDual,- hoursMultiEngineICUS, hoursMultiEngine, hoursSingleEngineInCommand,- hoursSingleEngineDual, hoursSingleEngineICUS, hoursSingleEngine,- hoursInAircraftRegistration, hoursInAircraftType,- hoursTotalInCommand, hoursTotalDual, hoursTotalICUS, hoursTotal,- flightsTotal) ) import Data.Foldable(foldr) import Data.Function(flip, ($)) import qualified Data.Map as Map(foldrWithKey)@@ -195,6 +178,10 @@ do span_ [class_ "key"] "in-command: " span_ [class_ "value"] . htmlTimeAmount $ r ^. hoursTotalInCommand+ li_ [] $+ do span_ [class_ "key"] "providing instruction: "+ span_ [class_ "value"] .+ htmlTimeAmount $ r ^. hoursInstructing li_ [] $ do span_ [class_ "key"] "Hours in type: " div_ [class_ "value"] .@@ -304,18 +291,40 @@ span_ [class_ "value"] . htmlTimeAmount $ r ^. hoursNightInCommand li_ [] $- do span_ [class_ "key"] "Hours providing instruction: "+ do span_ [class_ "key"] "providing instruction: " span_ [class_ "value"] . htmlTimeAmount $ r ^. hoursInstructing ul_ [] $ do li_ [] $- do span_ [class_ "key"] " RA instruction: "+ do span_ [class_ "key"] "providing RA instruction: " span_ [class_ "value"] . htmlTimeAmount $ r ^. hoursRAInstructing+ ul_ [] $+ do li_ [] $+ do span_ [class_ "key"] "providing RA Junior instruction: "+ span_ [class_ "value"] .+ htmlTimeAmount $ r ^. hoursRAJuniorInstructing+ li_ [] $+ do span_ [class_ "key"] "providing RA Senior instruction: "+ span_ [class_ "value"] .+ htmlTimeAmount $ r ^. hoursRASeniorInstructing li_ [] $- do span_ [class_ "key"] "GA instruction: "+ do span_ [class_ "key"] "providing GA instruction: " span_ [class_ "value"] . htmlTimeAmount $ r ^. hoursGAInstructing+ ul_ [] $+ do li_ [] $+ do span_ [class_ "key"] "providing GA 1 instruction: "+ span_ [class_ "value"] .+ htmlTimeAmount $ r ^. hoursGA1Instructing+ li_ [] $+ do span_ [class_ "key"] "providing GA 2 instruction: "+ span_ [class_ "value"] .+ htmlTimeAmount $ r ^. hoursGA2Instructing+ li_ [] $+ do span_ [class_ "key"] "providing GA 3 instruction: "+ span_ [class_ "value"] .+ htmlTimeAmount $ r ^. hoursGA3Instructing li_ [] $ do span_ [class_ "key"] "Hours with PiC: " div_ [class_ "value"] .
src/Data/Aviation/Casr/Logbook/Types/AircraftFlight.hs view
@@ -12,17 +12,22 @@ , noif_commandonlyflight , instructionflight , noif_instructionflight+, aeronauticalHours ) where import Control.Category((.))-import Control.Lens(makeClassy)+import Control.Lens ( view, makeClassy ) import Data.Aviation.Casr.Logbook.Types.Aircraft(Aircraft, HasAircraft(aircraft))-import Data.Aviation.Casr.Logbook.Types.Command ( Command(..) )-import Data.Aviation.Casr.Logbook.Types.DayNight(DayNight, HasDayNight(dayNight))+import Data.Aviation.Casr.Logbook.Types.Command+ ( Command(InCommandInstructing, InCommand, Dual, ICUS),+ isAeronauticalHours )+import Data.Aviation.Casr.Logbook.Types.DayNight+ ( DayNight(DayNight), HasDayNight(dayNight) ) import Data.Aviation.Casr.Logbook.Types.FlightPath(FlightPath, HasFlightPath(flightPath)) import Data.Aviation.Casr.Logbook.Types.Instruction ( Instruction ) import Data.Aviation.Casr.Logbook.Types.Aviator(Aviator)-import Data.Aviation.Casr.Logbook.Types.TimeAmount(TimeAmount, zerotimeamount)+import Data.Aviation.Casr.Logbook.Types.TimeAmount+ ( TimeAmount, zerotimeamount ) import Data.Eq(Eq) import Data.Ord(Ord) import Data.String(String)@@ -186,3 +191,13 @@ p [] zerotimeamount++aeronauticalHours ::+ AircraftFlight+ -> DayNight+aeronauticalHours fl =+ if isAeronauticalHours (view command fl)+ then+ view dayNight fl+ else+ DayNight zerotimeamount zerotimeamount
src/Data/Aviation/Casr/Logbook/Types/Command.hs view
@@ -5,11 +5,13 @@ Command(..) , AsCommand(..) , getUnderInstructionPic+, isAeronauticalHours ) where import Control.Lens(makeClassyPrisms) import Data.Aviation.Casr.Logbook.Types.Aviator(Aviator) import Data.Aviation.Casr.Logbook.Types.Instruction ( Instruction )+import Data.Bool ( Bool(..) ) import Data.Eq(Eq) import Data.Maybe(Maybe(Just, Nothing)) import Data.Ord(Ord)@@ -20,6 +22,7 @@ | Dual Aviator | InCommand | InCommandInstructing Instruction+ | ApprovedSolo Aviator deriving (Eq, Ord, Show) makeClassyPrisms ''Command@@ -35,3 +38,19 @@ Nothing getUnderInstructionPic (InCommandInstructing _) = Nothing+getUnderInstructionPic (ApprovedSolo _) =+ Nothing++isAeronauticalHours ::+ Command+ -> Bool+isAeronauticalHours (ICUS _) =+ True+isAeronauticalHours (Dual _) =+ True+isAeronauticalHours InCommand =+ True+isAeronauticalHours (InCommandInstructing _) =+ True+isAeronauticalHours (ApprovedSolo _) =+ False