-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow filtering availableFounders by slug
- Loading branch information
1 parent
de3d7c1
commit d7e93e1
Showing
4 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
defmodule Sanbase.Clickhouse.Founders do | ||
def get_founders() do | ||
query = get_founders_query() | ||
def get_founders(slug \\ nil) do | ||
query = get_founders_query(slug) | ||
|
||
Sanbase.ClickhouseRepo.query_transform(query, fn [name, slug] -> | ||
%{name: name, slug: slug} | ||
Sanbase.ClickhouseRepo.query_transform(query, fn [name, project_slug] -> | ||
%{name: name, slug: project_slug} | ||
end) | ||
end | ||
|
||
defp get_founders_query() do | ||
defp get_founders_query(nil) do | ||
sql = """ | ||
SELECT name, slug | ||
FROM founder_metadata | ||
""" | ||
|
||
Sanbase.Clickhouse.Query.new(sql, %{}) | ||
end | ||
|
||
defp get_founders_query(slug) do | ||
sql = """ | ||
SELECT name, slug | ||
FROM founder_metadata | ||
WHERE slug = {{slug}} | ||
""" | ||
|
||
Sanbase.Clickhouse.Query.new(sql, %{slug: slug}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters