Refactor ReposController

move querying logic to responsible models.

Address review comments