Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Sorting and line breaks for the download counts #72

Merged
merged 2 commits into from
Aug 29, 2018

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Aug 28, 2018

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 properties
  • canonical(1) to sort the properties by name

This 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.

@coveralls
Copy link

coveralls commented Aug 28, 2018

Coverage Status

Coverage remained the same at 92.076% when pulling 51dfe41 on HebaruSan:download-count-formatting into 1070491 on KSP-CKAN:master.

@@ -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);
Copy link
Member

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);
}

Copy link
Member

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);

Copy link
Member Author

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.

@techman83
Copy link
Member

Awesome! I'll deploy that soon.

@techman83 techman83 merged commit 051c7bf into KSP-CKAN:master Aug 29, 2018
@techman83
Copy link
Member

Next run will be with the new code.

@HebaruSan HebaruSan deleted the download-count-formatting branch November 19, 2018 18:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants