-
-
Notifications
You must be signed in to change notification settings - Fork 5
Sorting and line breaks for the download counts #72
Sorting and line breaks for the download counts #72
Conversation
lib/App/KSP_CKAN/DownloadCounts.pm
Outdated
@@ -10,7 +10,7 @@ use File::chdir; | |||
use File::Slurper qw(read_text write_text); | |||
use File::Basename qw(basename); | |||
use Try::Tiny; | |||
use JSON; | |||
use JSON::PP; | |||
use File::Path qw(mkpath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't be necessary to change to JSON::PP
. JSON
is a wrapper for a bunch of the modules available, it will prefer the library that links into the C parser (JSON::XS
) over the pure Perl (JSON::PP
) version. Both work the same, but XS is heaps faster and there were some build issues for the PP for a while there (only affected testing, we use XS in production).
->indent_length(0) | ||
->canonical(1) | ||
->allow_blessed(1) | ||
->convert_blessed(1); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these should be passable to plain JSON, looking at JSON:XS that'll be fine.
return JSON->new
->allow_blessed(1)
->convert_blessed(1)
->pretty(1)
->canonical(1);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, all of them work except for indent_length
, and I'm not about to argue for the necessity of zero indentation.
Awesome! I'll deploy that soon. |
Next run will be with the new code. |
Problem
The download counts code from #67 works!
However, the file format leaves a bit to be desired. The entire file is all one gigantic line, and the mods are listed in a randomized order which changes every time the file is generated. This means that every time the bot runs, the diff of this file will essentially amount to, "the whole thing changed again."
KSP-CKAN/CKAN-meta@25faf8d
Changes
indent(1)
to put line breaks between the propertiescanonical(1)
to sort the properties by nameThis will cause successive iterations of the
download_counts.json
file to have the mods listed in the same order, with each mod on its own line, which will make the diffs a bit more manageable.