Skip to content

Commit

Permalink
Really fix the performance issue with projects stats
Browse files Browse the repository at this point in the history
  • Loading branch information
simonprev committed Apr 4, 2024
1 parent d8b042e commit 8f18349
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
4 changes: 1 addition & 3 deletions lib/graphql/resolvers/project.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ defmodule Accent.GraphQL.Resolvers.Project do
Project
|> Query.join(:inner, [p], c in assoc(p, :collaborators))
|> Query.where([_, c], c.user_id == ^viewer.id)
|> Query.order_by([p, _], asc: p.name)
|> Query.order_by([p, _], desc_nulls_first: p.last_synced_at)
|> ProjectScope.from_search(args[:query])
|> ProjectScope.with_stats()
|> Paginated.paginate(args)
|> Paginated.format()

Expand All @@ -96,7 +95,6 @@ defmodule Accent.GraphQL.Resolvers.Project do
|> Query.join(:inner, [p], c in assoc(p, :collaborators))
|> Query.where([_, c], c.user_id == ^viewer.id)
|> ProjectScope.from_ids(args[:node_ids])
|> ProjectScope.with_stats()
|> Repo.all()

projects = Map.put(paginated_projects, :nodes, nodes_projects)
Expand Down
7 changes: 0 additions & 7 deletions test/graphql/requests/projects_request_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ defmodule AccentTest.GraphQL.Requests.Projects do
id
name
lastSyncedAt
translationsCount
conflictsCount
reviewedCount
}
}
}
Expand All @@ -52,9 +49,5 @@ defmodule AccentTest.GraphQL.Requests.Projects do

assert get_in(data, [:data, "viewer", "projects", "entries", Access.at(0), "lastSyncedAt"]) ===
"2017-01-01T00:00:00Z"

assert get_in(data, [:data, "viewer", "projects", "entries", Access.at(0), "translationsCount"]) === 3
assert get_in(data, [:data, "viewer", "projects", "entries", Access.at(0), "reviewedCount"]) === 1
assert get_in(data, [:data, "viewer", "projects", "entries", Access.at(0), "conflictsCount"]) === 2
end
end

0 comments on commit 8f18349

Please sign in to comment.