Skip to content

Conversation

ap
Copy link
Contributor

@ap ap commented Apr 21, 2018

Currently to figure out who can upload a new release of a distribution that will actually get indexed properly, you have to intersect the sets of the owner and co-maintainers of each module in your head. This is a job for a computer.

This PR makes the computer do it.

Copy link
Member

@haarg haarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ap
Copy link
Contributor Author

ap commented Apr 21, 2018

(Re-push only because the commits got mixed up when I tidied.)

Copy link
Member

@oalders oalders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Just the one change requested.

}
my @releaser
= sort grep { $num_modules_of{$_} == @$modules } keys %num_modules_of;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make the above code less succinct? It's not immediately obvious what is going on in lines 22-26. ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How? @haarg already reviewed it twice and asked me to make it clearer the first time, so I moved some things around slightly and gave the variables better names. Having done that, I’m not sure how I can make this algorithm any clearer, and I couldn’t think of any algorithm that will be easier to understand. Do you have any suggestion?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what ++$_ does and slices always confuse me shrug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I added some more variables. I don’t know if that helps…?

@oalders
Copy link
Member

oalders commented Apr 21, 2018

Thanks @ap!

@oalders
Copy link
Member

oalders commented Apr 21, 2018

t/controller/permission.t is currently failing. It's expecting an arrayref, but getting this instead:

{
          'co_maintainers' => [
                                'DOY',
                                'DROLSKY',
                                'ETHER',
                                'FLORA',
                                'GRODITI',
                                'HDP',
                                'MSTROUT',
                                'PERIGRIN',
                                'SARTAK'
                              ],
          'module_name' => 'Moose',
          'owner' => 'STEVAN'
        };

@haarg
Copy link
Member

haarg commented Apr 21, 2018

Seems that for a module it gets a single entry rather than an array. The API::Permission model seems a bit goofy.

@oalders
Copy link
Member

oalders commented Apr 21, 2018

Might just be a matter of returning an arrayref here: https://github.com/ap/metacpan-web/blob/whocan/lib/MetaCPAN/Web/Model/API/Permission.pm#L26

@ap
Copy link
Contributor Author

ap commented Apr 22, 2018

The API::Permission model seems a bit goofy.

Seems like it will be goofy either way… if you have a mode that always returns only one row, it’s goofy to make it inconsistent with the other modes (by not returning an array), and it’s goofy to make it wrap its result (when that mode on its own terms doesn’t need it). API consumers that look at all modes will want it consistent and API consumers that only ever use that particular mode will want it sensible-on-its-own…

t/controller/permission.t is currently failing. It's expecting an arrayref

Sorry, I could have caught that. It seemed odd for the module case to use the same data structure but my surface read of the code didn’t pick up anything that pointed in that direction so I just figured it was going to be fine, without any basis in fact.

Anyway, I put in a skip of the counting code for the module case. Regardless of whether you change the API, there’s not much of a point to counting total distinct PAUSE IDs across modules when there’s only one module, so I think fixing this makes sense on its own.

@oalders
Copy link
Member

oalders commented Apr 25, 2018

Thanks @ap!

@oalders oalders merged commit 22ff0bb into metacpan:master Apr 25, 2018
@ap ap deleted the whocan branch April 26, 2018 00:55
@ap
Copy link
Contributor Author

ap commented Apr 26, 2018

Thank you for shipping it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants