Compare commits

...

3 Commits

3 changed files with 13 additions and 7 deletions

View File

@ -1,4 +1,5 @@
# ExtensionDsLab # ExtensionDsLab
ExtensionDsLab is a data science and machine learning framework for analyzing ExtensionDsLab is a data science and machine learning framework for analyzing
security and privacy related properties of the browser extensions (and Chrome security and privacy related properties of the browser extensions (and Chrome
Apps) offered in the [Chrome Web Store](https://chrome.google.com/webstore/). Apps) offered in the [Chrome Web Store](https://chrome.google.com/webstore/).

View File

@ -45,11 +45,13 @@ module ExtensionQueries =
/// ///
/// **Exceptions** /// **Exceptions**
/// ///
/// * `MySql.Data.MySqlClient.MySqlException`
///
let getDownloads (ctx:ExtensionDbType) extid = let getDownloads (ctx:ExtensionDbType) extid =
query { query {
for order in ctx.Extensions.Extension do for order in ctx.Extensions.Extension do
where (order.Extid = extid && order.Downloads.IsSome) where (order.Extid = extid && order.Downloads.IsSome)
select (order.Date, order.Downloads.Value) select (order.Date, order.Downloads.Value)
} }
/// **Description** /// **Description**
@ -69,9 +71,11 @@ module ExtensionQueries =
/// ///
/// **Exceptions** /// **Exceptions**
/// ///
/// * `MySql.Data.MySqlClient.MySqlException`
///
let getAllExtIds (ctx:ExtensionDbType) = let getAllExtIds (ctx:ExtensionDbType) =
query { query {
for ext in ctx.Extensions.Extension do for ext in ctx.Extensions.Extension do
select ext.Extid select ext.Extid
distinct distinct
} }

View File

@ -31,7 +31,7 @@ open XPlot.GoogleCharts.Deedle
// the connection string shall be of the form // the connection string shall be of the form
// "Server=<DBHOST>;Database=extensions;User=<USER>;Password=<PASSWORD>" // "Server=<DBHOST>;Database=extensions;User=<USER>;Password=<PASSWORD>"
let ctx = ExtensionDbProvider.GetDataContext(connectionStringOrDefault "") let ctx = ExtensionDbProvider.GetDataContext(connectionStringOrDefault "",commandTimeout=36000)
// Log SQL: https://fsprojects.github.io/SQLProvider/core/querying.html // Log SQL: https://fsprojects.github.io/SQLProvider/core/querying.html
FSharp.Data.Sql.Common.QueryEvents.SqlQueryEvent |> Event.add (printfn "Executing SQL: %O") FSharp.Data.Sql.Common.QueryEvents.SqlQueryEvent |> Event.add (printfn "Executing SQL: %O")
@ -39,11 +39,11 @@ FSharp.Data.Sql.Common.QueryEvents.SqlQueryEvent |> Event.add (printfn "Executin
let chartDownloads extIds = (List.map (fun e -> (series (getDownloads ctx e))) extIds) let chartDownloads extIds = (List.map (fun e -> (series (getDownloads ctx e))) extIds)
|> Chart.Line |> Chart.Line
|> Chart.WithOptions (Options(legend=Legend(position="bottom"))) |> Chart.WithOptions (Options(legend=Legend(position="bottom"), width=1100))
|> Chart.WithLabels extIds |> Chart.WithLabels extIds
chartDownloads ["lkllajgbhondgjjnhmmgbjndmogapinp"] chartDownloads ["lkllajgbhondgjjnhmmgbjndmogapinp"]
// chartDownloads (List.take 5 (getAllExtIds ctx)) // chartDownloads (List.take 5 (getAllExtIds ctx |> Seq.toList))
let extData = let extData =
query {for x in ctx.Extensions.Extension do query {for x in ctx.Extensions.Extension do
@ -52,3 +52,4 @@ let extData =
|> Seq.map (fun (date, name, download) -> (date, name.Value, download.Value)) |> Seq.map (fun (date, name, download) -> (date, name.Value, download.Value))
|> Frame.ofRecords |> Frame.ofRecords
|> Frame.indexColsWith ["Date"; "Name"; "Downloads"] |> Frame.indexColsWith ["Date"; "Name"; "Downloads"]