ExtensionDsLab/src/scripts/example.fsx

65 lines
2.2 KiB
Plaintext
Raw Normal View History

2017-08-06 19:39:04 +00:00
(*
2017-08-06 20:12:14 +00:00
* This file is part of the ExtensionDsLab project.
* 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:34:43 +00:00
#I @"../../packages/SQLProvider/lib/"
#r @"FSharp.Data.SqlProvider.dll"
#I "../../packages/FSharp.Data/lib/net40"
#r "FSharp.Data.dll"
2017-08-12 19:47:35 +00:00
open Deedle
open FSharp.Data
open XPlot.GoogleCharts
open XPlot.GoogleCharts.Deedle
#I "../../bin/LogicalHacking.ExtensionDsLab"
#r "LogicalHacking.ExtensionDsLab.dll"
open LogicalHacking.ExtensionDsLab.Archive.SqlConnector
#load "../../packages/FsLab/Themes/DefaultWhite.fsx"
#load "../../packages/FsLab/FsLab.fsx"
2017-08-12 19:39:29 +00:00
let ctx = getCtx None Auto
2017-06-24 21:11:58 +00:00
2017-06-27 09:54:12 +00:00
let exts =
2017-08-12 19:39:29 +00:00
ctx.Main.Extension
2017-06-24 21:11:58 +00:00
|> Seq.map(fun c -> c.Extid)
2017-08-11 20:58:35 +00:00
|> Seq.distinct
2017-06-24 21:11:58 +00:00
|> Seq.toList
let ExtIds = ["aaagbdompnfgjaokopkpaceijcapjdde"
"aaahoedfmconkhncmkajlkallgnkjibh"
"aaahpjmadckbgmdbflcgblcnimbpfefg"
"aaaidlpoefeeklbhpndokmfipimojimj"
"aaaikdbhdiebhdogngakgnmjgpkpcmln"
]
2017-08-12 19:39:29 +00:00
let x = (List.map (fun e -> (series (getDownloads ctx e))) ExtIds)
|> Chart.Line
|> Chart.WithOptions (Options(legend=Legend(position="bottom")))
|> Chart.WithLabels ExtIds
2017-06-24 21:11:58 +00:00
let extData =
2017-08-12 19:39:29 +00:00
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"]