Last active
December 7, 2019 14:44
-
-
Save StefanBelo/111e91e82ac3be1352fff250903fd535 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I @"C:\Program Files (x86)\BeloSoft\Bfexplorer\" | |
#r "BeloSoft.Data.dll" | |
#r "BeloSoft.Bfexplorer.Domain.dll" | |
#r "BeloSoft.Bfexplorer.Service.Core.dll" | |
open System.Collections.Generic | |
open BeloSoft.Data | |
open BeloSoft.Bfexplorer.Domain | |
open BeloSoft.Bfexplorer.Service | |
type JockeyData(name : string) = | |
let mutable races = list<MarketSelection>.Empty | |
member _this.Name | |
with get() = name | |
member _this.Races | |
with get() = races | |
member _this.NumberOfRaces | |
with get() = races |> List.length | |
member _this.AddRace(marketSelection : MarketSelection) = | |
races <- races @ [ marketSelection ] | |
static member Create (name, marketSelection) = | |
let jockeyData = JockeyData(name) | |
jockeyData.AddRace(marketSelection) | |
jockeyData | |
let jockeys = Dictionary<string, JockeyData>() | |
let addJockeys (market : Market) = | |
market.Selections | |
|> Seq.filter isActiveSelection | |
|> Seq.iter (fun selection -> | |
selection.MetaData | |
|> Option.iter (fun selectionMetaData -> | |
let jockeyName = selectionMetaData.JockeyName | |
let marketSelection = | |
{ | |
MarketSelection.Market = market | |
MarketSelection.Selection = selection | |
} | |
let status, jockeyData = jockeys.TryGetValue jockeyName | |
if status | |
then | |
jockeyData.AddRace(marketSelection) | |
else | |
jockeys.[jockeyName] <- JockeyData.Create(jockeyName, marketSelection) | |
) | |
) | |
// Comment this line when executing in Bfexplorer Console | |
let bfexplorer : IBfexplorerConsole = nil | |
bfexplorer.OpenMarkets |> List.iter addJockeys | |
let jockeyDatas = jockeys.Values |> Seq.cast<JockeyData> |> Seq.toList | |
jockeyDatas | |
|> List.iter (fun jockeyData -> | |
printfn "%s (%d)" jockeyData.Name jockeyData.NumberOfRaces | |
) | |
let jockeyData = | |
jockeyDatas | |
|> List.sortByDescending (fun jockeyData -> jockeyData.NumberOfRaces) | |
|> List.head | |
printfn "%s:" jockeyData.Name | |
jockeyData.Races | |
|> List.iter (fun marketSelection -> | |
printfn "%s: %s | %d" marketSelection.Market.MarketInfo.MarketName marketSelection.Selection.Name marketSelection.Selection.Id | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment