ExtensionDsLab/src/LogicalHacking.ExtensionDsLab/Script.fsx

55 lines
2.1 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.
2018-07-11 22:23:04 +00:00
* Copyright (c) 2017, 2018 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/>.
2018-07-11 23:01:09 +00:00
*
* SPDX-License-Identifier: GPL-3.0-or-later
2017-08-06 19:39:04 +00:00
*)
2018-07-18 23:09:39 +00:00
#load "Themes/DefaultWhite.fsx"
2018-07-11 22:23:04 +00:00
#load "ExtensionDsLab.fsx"
2017-08-06 19:34:43 +00:00
2018-07-11 22:23:04 +00:00
open LogicalHacking.ExtensionDsLab
2018-07-23 05:10:27 +00:00
open LogicalHacking.ExtensionDsLab.Archive.DbConnector
open LogicalHacking.ExtensionDsLab.Archive.ExtensionQueries
2017-08-12 19:47:35 +00:00
open Deedle
open FSharp.Data
open XPlot.GoogleCharts
open XPlot.GoogleCharts.Deedle
2018-07-11 22:23:04 +00:00
// the connection string shall be of the form
// "Server=<DBHOST>;Database=extensions;User=<USER>;Password=<PASSWORD>"
let ctx = ExtensionDbProvider.GetDataContext(connectionStringOrDefault "")
// Log SQL: https://fsprojects.github.io/SQLProvider/core/querying.html
FSharp.Data.Sql.Common.QueryEvents.SqlQueryEvent |> Event.add (printfn "Executing SQL: %O")
let chartDownloads extIds = (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
chartDownloads ["lkllajgbhondgjjnhmmgbjndmogapinp"]
// chartDownloads (List.take 5 (getAllExtIds ctx))
2017-06-24 21:11:58 +00:00
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"]