| 1 | package App::lcpan::Cmd::mods_by_rdep_author_count; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Function::Fallback::CoreOrPP qw(clone_list); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | require App::lcpan; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||
| 12 | 1 | our $DATE = '2023-09-26'; # DATE | |||||||||||||||||||||||||||
| 13 | 1 | our $DIST = 'App-lcpan'; # DIST | |||||||||||||||||||||||||||
| 14 | 1 | our $VERSION = '1.074'; # VERSION | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | our %SPEC; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | $SPEC{'handle_cmd'} = { | |||||||||||||||||||||||||||
| 19 | v => 1.1, | ||||||||||||||||||||||||||||
| 20 | summary => 'List modules depended "by most number of authors" (modules ranked by number of authors that have dists that depend on the module)', | ||||||||||||||||||||||||||||
| 21 | args => { | ||||||||||||||||||||||||||||
| 22 | %App::lcpan::common_args, | ||||||||||||||||||||||||||||
| 23 | clone_list(%App::lcpan::deps_phase_args), | ||||||||||||||||||||||||||||
| 24 | clone_list(%App::lcpan::deps_rel_args), | ||||||||||||||||||||||||||||
| 25 | n => { | ||||||||||||||||||||||||||||
| 26 | summary => 'Return at most this number of results', | ||||||||||||||||||||||||||||
| 27 | schema => 'posint*', | ||||||||||||||||||||||||||||
| 28 | }, | ||||||||||||||||||||||||||||
| 29 | }, | ||||||||||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||||||||||
| 31 | 1 | delete $SPEC{'handle_cmd'}{args}{phase}{default}; | |||||||||||||||||||||||||||
| 32 | 1 | delete $SPEC{'handle_cmd'}{args}{rel}{default}; | |||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub handle_cmd { | ||||||||||||||||||||||||||
|
Subroutine
handle_cmd: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | my $state = App::lcpan::_init(\%args, 'ro'); | |||||||||||||||||||||||||||
| 37 | 0 | my $dbh = $state->{dbh}; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | my @where; | |||||||||||||||||||||||||||
| 40 | my @binds; | ||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ($args{phase} && $args{phase} ne 'ALL') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"phase"} and $args{"phase"} ne "ALL"
MC/DC0%0/2
$args{"phase"} and $args{"phase"} ne "ALL"
$args{"phase"}
$args{"phase"} ne "ALL"
Truth table0%0/3
A and B
A= $args{"phase"}B= $args{"phase"} ne "ALL"
| |||||||||||||||||||||||||||||
| 42 | 0 | push @where, "(phase=?)"; | |||||||||||||||||||||||||||
| 43 | 0 | push @binds, $args{phase}; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if ($args{rel} && $args{rel} ne 'ALL') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"rel"} and $args{"rel"} ne "ALL"
MC/DC0%0/2
$args{"rel"} and $args{"rel"} ne "ALL"
$args{"rel"}
$args{"rel"} ne "ALL"
Truth table0%0/3
A and B
A= $args{"rel"}B= $args{"rel"} ne "ALL"
| |||||||||||||||||||||||||||||
| 46 | 0 | push @where, "(rel=?)"; | |||||||||||||||||||||||||||
| 47 | 0 | push @binds, $args{rel}; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | @where = (1) if !@where; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | my $sql = "SELECT | ||||||||||||||||||||||||||||
| 52 | m.name module, | ||||||||||||||||||||||||||||
| 53 | m.cpanid author, | ||||||||||||||||||||||||||||
| 54 | COUNT(DISTINCT f.cpanid) AS rdep_author_count | ||||||||||||||||||||||||||||
| 55 | FROM module m | ||||||||||||||||||||||||||||
| 56 | JOIN dep dp ON dp.module_id=m.id | ||||||||||||||||||||||||||||
| 57 | LEFT JOIN file f ON dp.file_id=f.id | ||||||||||||||||||||||||||||
| 58 | WHERE ".join(" AND ", @where)." | ||||||||||||||||||||||||||||
| 59 | GROUP BY m.name | ||||||||||||||||||||||||||||
| 60 | ORDER BY rdep_author_count DESC | ||||||||||||||||||||||||||||
| 61 | 0 | ▶ | ".($args{n} ? " LIMIT ".(0+$args{n}) : ""); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | my @res; | |||||||||||||||||||||||||||
| 64 | 0 | my $sth = $dbh->prepare($sql); | |||||||||||||||||||||||||||
| 65 | 0 | $sth->execute(@binds); | |||||||||||||||||||||||||||
| 66 | 0 | ▶ | while (my $row = $sth->fetchrow_hashref) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | push @res, $row; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | require Data::TableData::Rank; | |||||||||||||||||||||||||||
| 71 | 0 | Data::TableData::Rank::add_rank_column_to_table(table => \@res, data_columns => ['rdep_author_count']); | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | my $resmeta = {}; | |||||||||||||||||||||||||||
| 74 | 0 | $resmeta->{'table.fields'} = [qw/rank module author rdep_author_count/]; | |||||||||||||||||||||||||||
| 75 | 0 | [200, "OK", \@res, $resmeta]; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | 1; | |||||||||||||||||||||||||||
| 79 | # ABSTRACT: List modules depended "by most number of authors" (modules ranked by number of authors that have dists that depend on the module) | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | __END__ | ||||||||||||||||||||||||||||