ExtensionDsLab/src/scripts/example.fsx

54 lines
1.9 KiB
Plaintext

(*
* This file is part of the ExtensionDsLab project.
* Copyright (c) 2017 LogicalHacking.com
*
* 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/>.
*)
#I @"../../packages/SQLProvider/lib/"
#r @"FSharp.Data.SqlProvider.dll"
#I "../../packages/FSharp.Data/lib/net40"
#r "FSharp.Data.dll"
#load "../../packages/FsLab/Themes/DefaultWhite.fsx"
#load "../../packages/FsLab/FsLab.fsx"
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
let ctx = ExtensionDbProvider.GetDataContext()
let chartDownloads extIds = (List.map (fun e -> (series (getDownloads ctx e))) extIds)
|> Chart.Line
|> Chart.WithOptions (Options(legend=Legend(position="bottom")))
|> Chart.WithLabels extIds
chartDownloads ["lkllajgbhondgjjnhmmgbjndmogapinp"]
// chartDownloads (List.take 5 (getAllExtIds ctx))
let extData =
query {for x in ctx.Extensions.Extension do
select (x.Date, x.Name, x.Downloads) }
|> Seq.filter (fun (date, name, download) -> name.IsSome && download.IsSome)
|> Seq.map (fun (date, name, download) -> (date, name.Value, download.Value))
|> Frame.ofRecords
|> Frame.indexColsWith ["Date"; "Name"; "Downloads"]