Minor refactoring.
This commit is contained in:
parent
00fd0aaa74
commit
3b919e1e1d
|
@ -30,28 +30,33 @@ module SqlConnector =
|
|||
+ @"/../resources/extensions-schema.sqlite"
|
||||
+ @";Version=3"
|
||||
// create a type alias with the connection string and database vendor settings
|
||||
type Sql = SqlDataProvider<
|
||||
ConnectionString = ConnectionString,
|
||||
DatabaseVendor = Common.DatabaseProviderTypes.SQLITE,
|
||||
// ResolutionPath = ResolutionPath,
|
||||
IndividualsAmount = 500,
|
||||
UseOptionTypes = true >
|
||||
type ExtensionDbProvider = SqlDataProvider<
|
||||
ConnectionString = ConnectionString,
|
||||
DatabaseVendor = Common.DatabaseProviderTypes.SQLITE,
|
||||
// ResolutionPath = ResolutionPath,
|
||||
IndividualsAmount = 500,
|
||||
UseOptionTypes = true >
|
||||
|
||||
type SqlType = Sql.dataContext
|
||||
type ExtensionDbType = ExtensionDbProvider.dataContext
|
||||
|
||||
type Db = Dev | Prod | Auto
|
||||
type Db = Dev | Prod | Auto | Custom of string
|
||||
let rec getCtx dir = let archiveDir = function
|
||||
| None -> __SOURCE_DIRECTORY__ + @"/../.."
|
||||
| Some s -> s
|
||||
function
|
||||
| Dev -> Sql.GetDataContext(sprintf "Data Source=%s/%s/%s;Version=3" (archiveDir dir) DatabaseDir DevelopmentDB)
|
||||
| Prod -> Sql.GetDataContext(sprintf "Data Source=%s/%s/%s;Version=3" (archiveDir dir) DatabaseDir FullDB)
|
||||
| Auto -> if File.Exists(sprintf "%s/%s/%s" (archiveDir dir) DatabaseDir FullDB) then
|
||||
getCtx dir Prod
|
||||
else
|
||||
getCtx dir Dev
|
||||
| Dev -> ExtensionDbProvider.GetDataContext(sprintf "Data Source=%s/%s/%s;Version=3"
|
||||
(archiveDir dir) DatabaseDir DevelopmentDB)
|
||||
| Prod -> ExtensionDbProvider.GetDataContext(sprintf "Data Source=%s/%s/%s;Version=3"
|
||||
(archiveDir dir) DatabaseDir FullDB)
|
||||
| Custom db -> ExtensionDbProvider.GetDataContext(sprintf "Data Source=%s/%s/%s;Version=3"
|
||||
(archiveDir dir) DatabaseDir db)
|
||||
| Auto -> if File.Exists(sprintf "%s/%s/%s" (archiveDir dir) DatabaseDir FullDB) then
|
||||
getCtx dir Prod
|
||||
else
|
||||
getCtx dir Dev
|
||||
|
||||
let getDownloads (ctx:SqlType) extid = query {
|
||||
let getDownloads (ctx:ExtensionDbType) extid =
|
||||
query {
|
||||
for order in ctx.Main.Extension do
|
||||
where (order.Extid = Some extid)
|
||||
select (order.Date, order.Downloads)
|
||||
|
|
|
@ -30,10 +30,10 @@ open LogicalHacking.ExtensionDsLab.Archive.SqlConnector
|
|||
#load "../../packages/FsLab/Themes/DefaultWhite.fsx"
|
||||
#load "../../packages/FsLab/FsLab.fsx"
|
||||
|
||||
let Ctx = getCtx None Auto
|
||||
let ctx = getCtx None Auto
|
||||
|
||||
let exts =
|
||||
Ctx.Main.Extension
|
||||
ctx.Main.Extension
|
||||
|> Seq.map(fun c -> c.Extid)
|
||||
|> Seq.distinct
|
||||
|> Seq.toList
|
||||
|
@ -55,20 +55,13 @@ open FSharp.Data
|
|||
open XPlot.GoogleCharts
|
||||
open XPlot.GoogleCharts.Deedle
|
||||
|
||||
let x = (List.map (fun e -> (series (getDownloads Ctx 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
|
||||
|
||||
|
||||
(*
|
||||
let permissionFrame = Ctx.Main.Crx |> Frame.ofRecords
|
||||
|
||||
permissionFrame.Print true |> ignore
|
||||
*)
|
||||
|
||||
let extData =
|
||||
query {for x in Ctx.Main.Extension do
|
||||
query {for x in ctx.Main.Extension do
|
||||
select (x.Date, x.Name, x.Downloads) }
|
||||
|> Seq.filter (fun (date, name, download) -> date.IsSome && name.IsSome && download.IsSome)
|
||||
|> Seq.map (fun (date, name, download) -> (System.DateTime.Parse(date.Value), name.Value,
|
||||
|
|
Loading…
Reference in New Issue