Skip to content

Commit

Permalink
refactor(chalice): return dashboard's owner email
Browse files Browse the repository at this point in the history
  • Loading branch information
tahayk committed Jul 1, 2024
1 parent d4beb8c commit 572dc6d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion api/chalicelib/core/custom_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ def search_all(project_id, user_id, data: schemas.SearchCardsSchema, include_ser

def get_all(project_id, user_id):
default_search = schemas.SearchCardsSchema()
result = rows = search_all(project_id=project_id, user_id=user_id, data=default_search)
result = []
rows = search_all(project_id=project_id, user_id=user_id, data=default_search)
while len(rows) == default_search.limit:
default_search.page += 1
rows = search_all(project_id=project_id, user_id=user_id, data=default_search)
Expand Down
7 changes: 6 additions & 1 deletion api/chalicelib/core/dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ def create_dashboard(project_id, user_id, data: schemas.CreateDashboardSchema):

def get_dashboards(project_id, user_id):
with pg_client.PostgresClient() as cur:
pg_query = f"""SELECT *
pg_query = f"""SELECT *, owner_email
FROM dashboards
LEFT JOIN LATERAL (SELECT email AS owner_email
FROM users
WHERE deleted_at ISNULL
AND users.user_id = dashboards.user_id
) AS owner ON (TRUE)
WHERE deleted_at ISNULL
AND project_id = %(projectId)s
AND (user_id = %(userId)s OR is_public);"""
Expand Down
3 changes: 2 additions & 1 deletion ee/api/chalicelib/core/custom_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ def search_all(project_id, user_id, data: schemas.SearchCardsSchema, include_ser

def get_all(project_id, user_id):
default_search = schemas.SearchCardsSchema()
result = rows = search_all(project_id=project_id, user_id=user_id, data=default_search)
result = []
rows = search_all(project_id=project_id, user_id=user_id, data=default_search)
while len(rows) == default_search.limit:
default_search.page += 1
rows = search_all(project_id=project_id, user_id=user_id, data=default_search)
Expand Down

0 comments on commit 572dc6d

Please sign in to comment.