// reference the type provider dll #r @"Mono.Data.Sqlite.dll" #r @"./packages/SQLProvider/lib/FSharp.Data.SqlProvider.dll" open FSharp.Data.Sql open System.IO let (+/) path1 path2 = Path.Combine(path1, path2) let [] DevelopmentDB = "aa-ac.sqlite" let [] FullDB = "full.sqlite" let [] DatabaseDir = "archive/db" // static (compile time) ResolutionPath and ConnectionString let [] ResolutionPath = __SOURCE_DIRECTORY__ + @"/lib" let [] ConnectionString = @"Data Source=" + __SOURCE_DIRECTORY__ + @"/" + DatabaseDir + @"/" + DevelopmentDB + @";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 > let Ctx = Sql.GetDataContext() // ResolutionPath,ConnectionString) // dynamic ResolutionPath and ConnectionString 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) |> Seq.toList #load "packages/FsLab/Themes/DefaultWhite.fsx" #load "packages/FsLab/FsLab.fsx" open Deedle open FSharp.Data open XPlot.GoogleCharts open XPlot.GoogleCharts.Deedle let ExtIds = ["aaagbdompnfgjaokopkpaceijcapjdde" "aaahoedfmconkhncmkajlkallgnkjibh" "aaahpjmadckbgmdbflcgblcnimbpfefg" "aaaidlpoefeeklbhpndokmfipimojimj" "aaaikdbhdiebhdogngakgnmjgpkpcmln" ] (List.map (fun e -> (series (getDownloads 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 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, download.Value)) |> Frame.ofRecords |> Frame.indexColsWith ["Date"; "Name"; "Downloads"]