1. 19 Jul, 2017 3 commits
    • Lin Jen-Shin's avatar
      Eliminate N+1 queries on checking different protected refs · a397a0eb
      Lin Jen-Shin authored
      I realized where the N+1 queries were actually coming from
      project.protected_branches, but how come we cannot preload this,
      or cache this at all?
      
      Then I found that this is somehow a Rails limitation. What we're
      doing before, eventually come to:
      
          project.protected_branches.matching
      
      But why it's not cached? (project.protected_branches.loaded? is always
      false) It's because matching is a class method, which is called on
      the proxy. In this case, Rails cannot cache the result. I don't know
      if this is possible to implement or not, because clearly this would
      require some tricks to implement class methods on associations.
      
      So instead, we could just pass project.protected_branches to
      ProtectedRef.matching, then it would work regularly.
      
      With this change, there's no more N+1 queries.
      a397a0eb
    • Lin Jen-Shin's avatar
      561bc570
    • Lin Jen-Shin's avatar
      Try to merge permission checks into one · b84eb343
      Lin Jen-Shin authored
      b84eb343
  2. 18 Jul, 2017 21 commits
  3. 17 Jul, 2017 16 commits