Created
October 21, 2014 20:28
-
-
Save sergey-tihon/ceaf835ef2df2d9bcf8f to your computer and use it in GitHub Desktop.
NuGet download stats
This file contains hidden or 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 @"packages\Nuget.Core.2.8.3\lib\net40-Client" | |
#r "NuGet.Core.dll" | |
#r "System.Xml.Linq.dll" | |
let repository = | |
NuGet.PackageRepositoryFactory.Default.CreateRepository | |
"https://nuget.org/api/v2" | |
type NuGetStat = | |
{ Id: string; DownloadCount:int} | |
let packages = | |
query { | |
for p in repository.GetPackages() do | |
where ( | |
p.Title.Contains "Fsharp" || | |
p.Title.Contains "FSharp" || | |
p.Title.Contains "fsharp" || | |
p.Title.Contains "F#" || | |
p.Tags.Contains "fsharp" || | |
p.Tags.Contains "F#" || | |
p.Tags.Contains "f#") | |
select p | |
} | |
|> Seq.toArray | |
let fsharp = | |
packages | |
|> Seq.filter (fun p -> | |
let s = if p = null || p.Title = null then "" else p.Title.ToLowerInvariant() | |
let pos = s.IndexOf("fsharp") | |
if pos<=0 then true else not <| System.Char.IsLetter(s.[pos-1]) | |
) | |
|> Seq.groupBy (fun p -> p.Id) | |
|> Seq.map (fun (key, packages) -> | |
{Id=key; | |
DownloadCount = (packages |> Seq.maxBy (fun x->x.DownloadCount)).DownloadCount}) | |
|> Seq.sortBy (fun x -> -x.DownloadCount) | |
|> Seq.toArray | |
#load @"packages\Deedle.1.0.6\Deedle.fsx" | |
open Deedle | |
let frame = Frame.ofRecords fsharp | |
frame.SaveCsv("d:\\nuget_fsharp.csv") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment