Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewChubatiuk committed Apr 29, 2024
1 parent 6860cca commit 8398d6e
Show file tree
Hide file tree
Showing 21 changed files with 182 additions and 172 deletions.
26 changes: 13 additions & 13 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ botocore = "1.31.8"
cassandra-driver = "3.21.0"
certifi = ">=2019.9.11"
cmem-cmempy = "21.2.3"
databend-driver = "0.12.5"
databend-sqlalchemy = "0.4.4"
databend-driver = "0.17.1"
databend-sqlalchemy = "0.4.6"
google-api-python-client = "1.7.11"
gspread = "5.11.2"
impyla = "0.16.0"
Expand Down
1 change: 0 additions & 1 deletion redash/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def create_app():
from redash.metrics import request as request_metrics
from redash.models import db, users
from redash.utils import sentry
from redash.version_check import reset_new_version_status

from . import (
limiter,
Expand Down
8 changes: 2 additions & 6 deletions redash/cli/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,9 @@ def delete(email, organization=None):
if organization:
org = models.Organization.get_by_slug(organization)
deleted_users_query = deleted_users_query.where(models.User.org == org)

Check warning on line 208 in redash/cli/users.py

View check run for this annotation

Codecov / codecov/patch

redash/cli/users.py#L208

Added line #L208 was not covered by tests
deleted_count = len(
models.db.session.scalars(
deleted_users_query.returning(models.User.id).execution_options(synchronize_session=False)
).all()
)
result = models.db.session.execute(deleted_users_query.execution_options(synchronize_session=False))
models.db.session.commit()
print("Deleted %d users." % deleted_count)
print("Deleted %d users." % result.rowcount)


@manager.command()
Expand Down
2 changes: 1 addition & 1 deletion redash/destinations/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def notify(self, alert, query, user, new_state, app, host, metadata, options):
]
if alert.custom_body:
fields.append({"name": "Description", "value": alert.custom_body})
if new_state == Alert.TRIGGERED_STATE:
if new_state == Alerts.TRIGGERED_STATE:
if alert.options.get("custom_subject"):
text = alert.options["custom_subject"]
else:
Expand Down
33 changes: 16 additions & 17 deletions redash/handlers/organization.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from flask_login import current_user, login_required
from sqlalchemy import distinct, func
from sqlalchemy.sql.expression import select

from redash import models
from redash.authentication import current_org
Expand All @@ -12,34 +11,34 @@
@login_required
def organization_status(org_slug=None):
counters = {
"users": models.db.session.execute(
models.User.all(current_org, columns=[func.count(models.User.id)])
).first()[0],
"alerts": models.db.session.execute(
models.Alert.all(
group_ids=current_user.group_ids, columns=[func.count(models.Alert.id)], distinct=[]
)
).first()[0],
"data_sources": models.db.session.execute(
"users": models.db.session.scalar(models.User.all(current_org, columns=[func.count(models.User.id)])),
"alerts": models.db.session.scalar(
models.Alert.all(group_ids=current_user.group_ids, columns=[func.count(models.Alert.id)], distinct=[])
),
"data_sources": models.db.session.scalar(
models.DataSource.all(
current_org,
group_ids=current_user.group_ids,
columns=[func.count(models.DataSource.id)],
)
).first()[0],
"queries": models.db.session.execute(
),
"queries": models.db.session.scalar(
models.Query.all(
current_user.group_ids,
user_id=current_user.id,
include_drafts=True,
columns=[func.count(distinct(models.Query.id))],
)
).first()[0],
"dashboards": models.db.session.execute(
select(func.count(models.Dashboard.id)).where(
models.Dashboard.org == current_org, models.Dashboard.is_archived.is_(False)
),
"dashboards": models.db.session.scalar(
models.Dashboard.all(
current_org,
[],
None,
columns=[func.count(distinct(models.Dashboard.id))],
distinct=[],
)
).first()[0],
),
}

return json_response(dict(object_counters=counters))

0 comments on commit 8398d6e

Please sign in to comment.