Moved getDownloads to SqlConnector.
This commit is contained in:
parent
8a01f07dea
commit
00fd0aaa74
|
@ -37,7 +37,8 @@ module SqlConnector =
|
|||
IndividualsAmount = 500,
|
||||
UseOptionTypes = true >
|
||||
|
||||
|
||||
type SqlType = Sql.dataContext
|
||||
|
||||
type Db = Dev | Prod | Auto
|
||||
let rec getCtx dir = let archiveDir = function
|
||||
| None -> __SOURCE_DIRECTORY__ + @"/../.."
|
||||
|
@ -48,4 +49,13 @@ module SqlConnector =
|
|||
| Auto -> if File.Exists(sprintf "%s/%s/%s" (archiveDir dir) DatabaseDir FullDB) then
|
||||
getCtx dir Prod
|
||||
else
|
||||
getCtx dir Dev
|
||||
getCtx dir Dev
|
||||
|
||||
let getDownloads (ctx:SqlType) extid = query {
|
||||
for order in ctx.Main.Extension do
|
||||
where (order.Extid = Some extid)
|
||||
select (order.Date, order.Downloads)
|
||||
} |> Seq.filter (fun (date, download) -> date.IsSome && download.IsSome)
|
||||
|> Seq.map (fun (date, download) -> (System.DateTime.Parse(date.Value),
|
||||
download.Value))
|
||||
|> Seq.toArray
|
|
@ -32,15 +32,6 @@ open LogicalHacking.ExtensionDsLab.Archive.SqlConnector
|
|||
|
||||
let Ctx = getCtx None Auto
|
||||
|
||||
let getDownloads extid = query {
|
||||
for order in Ctx.Main.Extension do
|
||||
where (order.Extid = Some extid)
|
||||
select (order.Date, order.Downloads)
|
||||
} |> Seq.filter (fun (date, download) -> date.IsSome && download.IsSome)
|
||||
|> Seq.map (fun (date, download) -> (System.DateTime.Parse(date.Value),
|
||||
download.Value))
|
||||
|> Seq.toArray
|
||||
|
||||
let exts =
|
||||
Ctx.Main.Extension
|
||||
|> Seq.map(fun c -> c.Extid)
|
||||
|
@ -64,7 +55,7 @@ open FSharp.Data
|
|||
open XPlot.GoogleCharts
|
||||
open XPlot.GoogleCharts.Deedle
|
||||
|
||||
let x = (List.map (fun e -> (series (getDownloads e))) ExtIds)
|
||||
let x = (List.map (fun e -> (series (getDownloads Ctx e))) ExtIds)
|
||||
|> Chart.Line
|
||||
|> Chart.WithOptions (Options(legend=Legend(position="bottom")))
|
||||
|> Chart.WithLabels ExtIds
|
||||
|
|
Loading…
Reference in New Issue