Improve the query to get top authors so that it doesn't use companies-related tables (reopen)

Improve the query to get top authors so that it doesn't use the companies-related tables if no filter on companies is used. This allows to work on databases without companies tables when they are not really needed.
(I couldn't reopen #21, which I closed by error, so I open a new pull request)