Created
December 7, 2018 14:47
-
-
Save porfirion/a245fe6b466e6bc2f25356e1dab3776a 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
let print (slots:(int * string * string * string * int * string) list) (token: string) = | |
// (article_id * slot_id * hash * realHash * options_count * slot_title) | |
[ | |
"By title and hash:\n" | |
slots | |
|> List.groupBy (fun slot -> | |
let articleId, slotId, slotHash, slotRealHash, optionsCount, title = slot | |
title | |
) | |
|> List.map (fun (title, entries) -> | |
[ | |
sprintf "\t%s:\n" title | |
entries | |
|> List.groupBy (fun entry -> | |
let articleId, slotId, slotHash, slotRealHash, optionsCount, title = entry | |
sprintf "%s (%5d)" slotHash optionsCount) | |
|> List.map (fun (hash, slots) -> | |
let articleIds: string = | |
slots | |
|> List.map (fun slot -> | |
let articleId, slotId, slotHash, slotRealHash, optionsCount, title = slot | |
articleId.ToString() | |
) | |
|> String.concat "," | |
sprintf "\t\t\t%s: [%s]\n" hash articleIds | |
) | |
|> String.concat "" | |
] | |
) | |
|> List.concat | |
|> String.concat "" | |
"By real hash:\n" | |
slots | |
|> List.groupBy (fun slot -> | |
let articleId, slotId, slotHash, slotRealHash, optionsCount, title = slot | |
slotRealHash | |
) | |
|> List.map (fun (realHash, entries) -> | |
[ | |
sprintf "\t%s:\n" realHash | |
entries | |
|> List.groupBy (fun entry -> | |
let articleId, slotId, slotHash, slotRealHash, optionsCount, title = entry | |
sprintf "\t\t----------%s\n\t\t %s (%5d options)" title slotHash optionsCount) | |
|> List.map (fun (titleAndHash, slots) -> | |
let articleIds: string = | |
slots | |
|> List.map (fun slot -> | |
let articleId, slotId, slotHash, slotRealHash, optionsCount, title = slot | |
articleId.ToString() | |
) | |
|> String.concat "," | |
sprintf "%s\n\t\t [%s]\n" titleAndHash articleIds | |
) | |
|> String.concat "" | |
]) | |
|> List.concat | |
|> String.concat "" | |
] | |
|> String.concat "" | |
|> Parser.LogToFile token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment