Skip to content

Commit

Permalink
fix ameba warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mamantoha committed Dec 23, 2024
1 parent 0605b6d commit 93f0720
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/models/repository.cr
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ class Repository

scope(:published) { where({ignore: false}) }

scope(:without_releases) {
scope(:without_releases) do
where(<<-SQL
NOT (
EXISTS (SELECT "releases".* FROM "releases" WHERE (releases.repository_id = repositories.id))
)
SQL
)
}
end

# ```
# repositories = Repository.query.with_counts
Expand All @@ -61,26 +61,26 @@ class Repository
# repository.attributes["dependents_count"]
# end
# ```
scope(:with_counts) {
scope(:with_counts) do
self
.select(
"repositories.*",
"(select COUNT(*) from relationships r WHERE r.dependency_id=repositories.id) dependents_count",
"(select COUNT(*) from relationships r WHERE r.master_id=repositories.id) dependencies_count"
)
.group_by("repositories.id")
}
end

def self.find_repository(user_login : String, repository_name : String, provider : String) : Repository?
Repository
.query
.join("users") { users.id == repositories.user_id }
.find {
.find do
(users.login == user_login) &
(users.provider == provider) &
(repositories.provider == provider) &
(repositories.name == repository_name)
}
end
end

def decorate
Expand Down

0 comments on commit 93f0720

Please sign in to comment.