Skip to content

Commit

Permalink
el typinh
Browse files Browse the repository at this point in the history
  • Loading branch information
Christinarlong committed Sep 22, 2024
1 parent 9836d51 commit c82e0b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,20 @@ def get(self, request: Request, sentry_app) -> Response:
sentry_app_id=sentry_app.id, date_deleted__isnull=False
).count()

rollup, series = tsdb.get_optimal_rollup_series(query_args["start"], query_args["end"])
rollup, series = tsdb.backend.get_optimal_rollup_series(
query_args["start"], query_args["end"]
)

install_stats = dict.fromkeys(series, 0)
uninstall_stats = dict.fromkeys(series, 0)

for date_added, date_deleted, organization_id in installations:
install_norm_epoch = tsdb.normalize_to_epoch(date_added, rollup)
install_norm_epoch = tsdb.backend.normalize_to_epoch(date_added, rollup)
if install_norm_epoch in install_stats:
install_stats[install_norm_epoch] += 1

if date_deleted is not None:
uninstall_norm_epoch = tsdb.normalize_to_epoch(date_deleted, rollup)
uninstall_norm_epoch = tsdb.backend.normalize_to_epoch(date_deleted, rollup)
if uninstall_norm_epoch in uninstall_stats:
uninstall_stats[uninstall_norm_epoch] += 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
)
from sentry.api.serializers.models.apitoken import ApiTokenSerializer
from sentry.exceptions import ApiTokenLimitError
from sentry.interfaces.user import User
from sentry.models.apitoken import ApiToken
from sentry.sentry_apps.installations import SentryAppInstallationTokenCreator
from sentry.sentry_apps.models.sentry_app import MASKED_VALUE
from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation
from sentry.users.services.user.model import RpcUser


@control_silo_endpoint
Expand Down Expand Up @@ -61,6 +63,9 @@ def post(self, request: Request, sentry_app) -> Response:
)
sentry_app_installation = SentryAppInstallation.objects.get(sentry_app_id=sentry_app.id)
try:
assert isinstance(request.user, User) or isinstance(
request.user, RpcUser
), "User must be authenticated to install a sentry app"
api_token = SentryAppInstallationTokenCreator(
sentry_app_installation=sentry_app_installation
).run(request=request, user=request.user)
Expand Down

0 comments on commit c82e0b1

Please sign in to comment.