In our Ruby on Rails app, we have a set of conditions to define the status of a user. Currently, there is logic that checks if those conditions are true given a user. We are in the process of writing code that will fetch a set of users from the database based on these conditions.
A couple of my colleagues believe that we should reuse the logic for checks and loop over the entire set of queried records as opposed to writing a complex query to fetch the set. Their reason is that the definition of conditions would remain in one place and would help avoid maintenance overhead in case the definitions change.
On the other hand, I think the processes are inverses of each other and the maintenance overhead is desirable over the inefficient code approach.