diff --git a/lib/kmxgit/organisation_manager/organisation.ex b/lib/kmxgit/organisation_manager/organisation.ex
index f9065c2..90f30a1 100644
--- a/lib/kmxgit/organisation_manager/organisation.ex
+++ b/lib/kmxgit/organisation_manager/organisation.ex
@@ -29,18 +29,26 @@ defmodule Kmxgit.OrganisationManager.Organisation do
end
def owner?(org, user) do
- org.users
- |> Enum.find(fn u ->
- u.id == user.id
- end)
+ if user do
+ org.users
+ |> Enum.find(fn u ->
+ u.id == user.id
+ end)
+ end
end
def owned_repositories(org) do
- org.owned_repositories
- |> Enum.sort_by(&Repository.full_slug/1)
+ if org do
+ org.owned_repositories
+ |> Enum.sort_by(&Repository.full_slug/1)
+ end
end
def disk_usage(org) do
- GitManager.dir_disk_usage(org.slug.slug)
+ if org do
+ GitManager.dir_disk_usage(org.slug.slug)
+ else
+ 0
+ end
end
end
diff --git a/lib/kmxgit/repository_manager.ex b/lib/kmxgit/repository_manager.ex
index eaef52e..c60f8b0 100644
--- a/lib/kmxgit/repository_manager.ex
+++ b/lib/kmxgit/repository_manager.ex
@@ -82,13 +82,15 @@ defmodule Kmxgit.RepositoryManager do
Repo.one from repo in Repository, select: count()
end
- def list_contributor_repositories(user) do
- list_repositories()
+ def list_contributor_repositories(user, params = %IndexParams{} \\ %IndexParams{per: 1000000}) do
+ pagination = list_repositories(params)
+ result = pagination.result
|> Enum.filter(fn repo ->
(!repo.user || repo.user.id != user.id) &&
(Repository.members(repo)
|> Enum.find(fn u -> u.id == user.id end))
end)
+ result
end
def change_repository() do