2017-08-06 19:39:04 +00:00
|
|
|
(*
|
2017-08-06 20:12:14 +00:00
|
|
|
* This file is part of the ExtensionDsLab project.
|
2017-08-06 19:55:24 +00:00
|
|
|
* Copyright (c) 2017 LogicalHacking.com
|
2017-08-06 19:39:04 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*)
|
2017-08-06 19:55:24 +00:00
|
|
|
|
2017-06-27 09:54:12 +00:00
|
|
|
#r @"Mono.Data.Sqlite.dll"
|
2017-08-06 19:34:43 +00:00
|
|
|
#I @"../../packages/SQLProvider/lib/"
|
|
|
|
#r @"FSharp.Data.SqlProvider.dll"
|
|
|
|
|
2017-06-24 21:11:58 +00:00
|
|
|
open FSharp.Data.Sql
|
2017-06-27 09:54:12 +00:00
|
|
|
open System.IO
|
|
|
|
let (+/) path1 path2 = Path.Combine(path1, path2)
|
2017-06-24 21:11:58 +00:00
|
|
|
|
2017-07-01 20:48:27 +00:00
|
|
|
let [<Literal>] DevelopmentDB = "aa-ac.sqlite"
|
2017-06-27 09:54:12 +00:00
|
|
|
let [<Literal>] FullDB = "full.sqlite"
|
|
|
|
let [<Literal>] DatabaseDir = "archive/db"
|
2017-08-06 19:55:24 +00:00
|
|
|
// static (compile time) ConnectionString
|
2017-06-27 09:54:12 +00:00
|
|
|
let [<Literal>] ConnectionString = @"Data Source="
|
|
|
|
+ __SOURCE_DIRECTORY__
|
2017-08-06 19:55:24 +00:00
|
|
|
+ @"/../.."
|
2017-06-27 09:54:12 +00:00
|
|
|
+ @"/" + DatabaseDir
|
|
|
|
+ @"/" + DevelopmentDB + @";Version=3"
|
2017-06-24 21:11:58 +00:00
|
|
|
// create a type alias with the connection string and database vendor settings
|
|
|
|
type Sql = SqlDataProvider<
|
|
|
|
ConnectionString = ConnectionString,
|
|
|
|
DatabaseVendor = Common.DatabaseProviderTypes.SQLITE,
|
2017-06-27 09:54:12 +00:00
|
|
|
// ResolutionPath = ResolutionPath,
|
2017-06-24 21:11:58 +00:00
|
|
|
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
|
|
|
|
|
2017-06-27 09:54:12 +00:00
|
|
|
let exts =
|
2017-06-24 21:11:58 +00:00
|
|
|
Ctx.Main.Extension
|
|
|
|
|> Seq.map(fun c -> c.Extid)
|
|
|
|
|> Seq.toList
|
|
|
|
|
|
|
|
|
2017-08-06 19:55:24 +00:00
|
|
|
#load "../../packages/FsLab/Themes/DefaultWhite.fsx"
|
|
|
|
#load "../../packages/FsLab/FsLab.fsx"
|
2017-06-24 21:11:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
let ExtIds = ["aaagbdompnfgjaokopkpaceijcapjdde"
|
|
|
|
"aaahoedfmconkhncmkajlkallgnkjibh"
|
|
|
|
"aaahpjmadckbgmdbflcgblcnimbpfefg"
|
|
|
|
"aaaidlpoefeeklbhpndokmfipimojimj"
|
|
|
|
"aaaikdbhdiebhdogngakgnmjgpkpcmln"
|
2017-08-06 19:55:24 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
open Deedle
|
|
|
|
open FSharp.Data
|
|
|
|
open XPlot.GoogleCharts
|
|
|
|
open XPlot.GoogleCharts.Deedle
|
2017-06-24 21:11:58 +00:00
|
|
|
|
2017-08-06 19:55:24 +00:00
|
|
|
let x = (List.map (fun e -> (series (getDownloads e))) ExtIds)
|
|
|
|
|> Chart.Line
|
|
|
|
|> Chart.WithOptions (Options(legend=Legend(position="bottom")))
|
|
|
|
|> Chart.WithLabels ExtIds
|
2017-06-24 21:11:58 +00:00
|
|
|
|
2017-06-27 09:54:57 +00:00
|
|
|
|
2017-08-06 19:55:24 +00:00
|
|
|
(*
|
|
|
|
let permissionFrame = Ctx.Main.Crx |> Frame.ofRecords
|
2017-06-27 09:54:57 +00:00
|
|
|
|
2017-08-06 19:55:24 +00:00
|
|
|
permissionFrame.Print true |> ignore
|
|
|
|
*)
|
2017-06-27 09:54:57 +00:00
|
|
|
|
|
|
|
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"]
|
|
|
|
|
|
|
|
|