1. 09 10月, 2018 2 次提交
  2. 08 10月, 2018 2 次提交
    • Y
      Clean up ActiveRecord code in TodoService · 38b8ae64
      Yorick Peterse 提交于
      This refactors the TodoService class according to our code reuse
      guidelines. The resulting code is a wee bit more verbose, but it allows
      us to decouple the column names from the input, resulting in fewer
      changes being necessary when we change the schema.
      
      One particular noteworthy line in TodoService is the following:
      
          todos_ids = todos.update_state(state)
      
      Technically this is a violation of the guidelines, because
      `update_state` is a class method, which services are not supposed to use
      (safe for a few allowed ones). I decided to keep this, since there is no
      alternative. `update_state` doesn't produce a relation so it doesn't
      belong in a Finder, and we can't move it to another Service either. As
      such I opted to just use the method directly.
      
      Cases like this may happen more frequently, at which point we should
      update our documentation with some sort of recommendation. For now, I
      want to refrain from doing so until we have a few more examples.
      38b8ae64
    • Y
      Clean up ActiveRecord code in TodosFinder · 4c1dc310
      Yorick Peterse 提交于
      This refactors the TodosFinder finder according to the new code reuse
      rules, as enforced by the CodeReuse cops. I also changed some of the
      methods to use regular if statements, instead of assignments and/or
      early returns. This results in a more natural flow when reading the
      code, and it makes it harder to accidentally return the wrong result.
      4c1dc310
  3. 07 10月, 2018 2 次提交
  4. 06 10月, 2018 13 次提交
  5. 05 10月, 2018 18 次提交
  6. 04 10月, 2018 3 次提交
    • A
      fix method name in stage spec · acfe7ec6
      Alessio Caiazza 提交于
      acfe7ec6
    • S
      Fix N+1 for notification recipients on private projects · 28e6af88
      Sean McGivern 提交于
      If we don't call #to_a, we're relying on the members already being loaded from
      elsewhere. Otherwise we'll do a separate query for each user:
      
          [1] pry(main)> Project.first.team.members.include?(User.first)
            Project Load (0.7ms)  SELECT  "projects".* FROM "projects"  ORDER BY "projects"."id" ASC LIMIT 1
            ↳ (pry):3
            User Load (1.8ms)  SELECT  "users".* FROM "users"  ORDER BY "users"."id" ASC LIMIT 1
            ↳ (pry):3
            User Exists (0.6ms)  SELECT  1 AS one FROM "users" INNER JOIN "project_authorizations" ON "users"."id" = "project_authorizations"."user_id" WHERE "project_authorizations"."project_id" = $1 AND "users"."id" = $2 LIMIT 1  [["project_id", 1], ["id", 1]]
            ↳ (pry):3
          => true
          [2] pry(main)> Project.first.team.members.to_a.include?(User.first)
            Project Load (12.8ms)  SELECT  "projects".* FROM "projects"  ORDER BY "projects"."id" ASC LIMIT 1
            ↳ (pry):1
            User Load (9.6ms)  SELECT "users".* FROM "users" INNER JOIN "project_authorizations" ON "users"."id" = "project_authorizations"."user_id" WHERE "project_authorizations"."project_id" = $1  [["project_id", 1]]
            ↳ (pry):1
            User Load (0.6ms)  SELECT  "users".* FROM "users"  ORDER BY "users"."id" ASC LIMIT 1
            ↳ (pry):1
          => true
      28e6af88
    • S
      Fix N+1 for notification recipients in subscribers · 819ecd5f
      Sean McGivern 提交于
      819ecd5f