Query tickets within the users_controller.rb


I’m working on suppressing inactive users within the autocompletion. I realized that probably the search method within users_controller.rb is responsible for this. Within this method, I see something like this:

    # build result list
    tickets = Ticket.search(
      query: query,
      condition: params[:condition].to_h,
      limit: per_page,
      offset: offset,
      current_user: current_user,

I don’t understand why this is done. Why bother querying the tickets when in the end just a list of users should be generated?

Note: I’m not a ruby developer, so maybe my question is stupid… Thanks for helping anyway + best regards, Uli


I also just stumbled over this; luckily Discourse prevented me from opening a new topic.

This looks like a copy-and-paste error to me - that code block seems to originate from ./tickets_controller.rb and was introduced in cf1626494047f27d8fe094a7b954e04fef0f182b:

commit cf1626494047f27d8fe094a7b954e04fef0f182b
Author: Martin Edenhofer <me@edenhofer.de>
Date:   Fri Apr 13 09:22:55 2018 +0200

    Implemented issue #1951 - Allow pagination in search result with more then 100 results.

tickets isn’t actually used afterwards in users_controller.rb. @thorsteneckel should I file a bug?


Yes - you’re both right. That’s a copy paste error. I already stumbled across it while applying a (currently) deactivated rubocop cop but unfortunately hadn’t hat the time to finish things :confused: I’d love to merge a MR removing this unnecessary block!


I’ll look into it. In general - should I file a bug report before filing a merge request, or a merge request only?


Thanks! A simple MR is sufficient - the changes are pretty clear and only refactoring/maintenance.