Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Last active October 5, 2017 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/db0b415769ba4fe2e66cd362957dae51 to your computer and use it in GitHub Desktop.
Save zoffixznet/db0b415769ba4fe2e66cd362957dae51 to your computer and use it in GitHub Desktop.
diff --git a/lib/ModulesPerl6/Model/Dists.pm b/lib/ModulesPerl6/Model/Dists.pm
index 4e10289..021a9ae 100644
--- a/lib/ModulesPerl6/Model/Dists.pm
+++ b/lib/ModulesPerl6/Model/Dists.pm
@@ -3,6 +3,7 @@ package ModulesPerl6::Model::Dists;
use Carp qw/croak/;
use File::Spec::Functions qw/catfile/;
use FindBin; FindBin->again;
+use List::UtilsBy qw/uniq_by/;
use Mojo::Collection qw/c/;
use Mojo::Util qw/trim/;
use ModulesPerl6::Model::Dists::Schema;
@@ -50,14 +51,19 @@ sub _find {
} : ()
);
- return $is_hri ? c map {
- # TODO XXX: there got to be a better way to do this?
- $_->{tags} = [ sort map $_->{tag}{tag}, @{ delete $_->{tag_dists} } ];
- $_->{problems} = [ sort map $_->{problem}, @{ delete $_->{problem_dists} } ];
- $_->{date_updated_human} = $_->{date_updated}
- ? strftime '%Y-%m-%d', localtime $_->{date_updated} : 'N/A';
- $_
- } $res->all : $res;
+ return $is_hri ? c(
+ uniq_by { join "\0", @$_{qw/name dist_source author_id/ } }
+ map {
+ # TODO XXX: there got to be a better way to do this?
+ $_->{tags}
+ = [ sort map $_->{tag}{tag}, @{ delete $_->{tag_dists} } ];
+ $_->{problems}
+ = [ sort map $_->{problem}, @{ delete $_->{problem_dists} } ];
+ $_->{date_updated_human} = $_->{date_updated}
+ ? strftime '%Y-%m-%d', localtime $_->{date_updated} : 'N/A';
+ $_
+ } $res->all
+ ) : $res;
}
sub add {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment