Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/environment/api/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ func (s *EnvironmentService) getOrganization(
) (*domain.Organization, error) {
org, err := s.orgStorage.GetOrganization(ctx, id)
if err != nil {
s.logger.Error("failed to get organization",
log.FieldsFromImcomingContext(ctx).AddFields(
zap.String("organizationId", id),
zap.Error(err),
)...)
if errors.Is(err, v2es.ErrOrganizationNotFound) {
dt, err := statusOrganizationNotFound.WithDetails(&errdetails.LocalizedMessage{
Locale: localizer.GetLocale(),
Expand Down
3 changes: 3 additions & 0 deletions pkg/environment/storage/v2/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ func (s *organizationStorage) GetOrganization(ctx context.Context, id string) (*
&organization.SystemAdmin,
&organization.CreatedAt,
&organization.UpdatedAt,
&organization.ProjectCount,
&organization.EnvironmentCount,
&organization.UserCount,
)
if err != nil {
if errors.Is(err, mysql.ErrNoRows) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
SELECT
id,
name,
owner_email,
url_code,
description,
disabled,
archived,
trial,
system_admin,
created_at,
updated_at
organization.id,
organization.name,
organization.owner_email,
organization.url_code,
organization.description,
organization.disabled,
organization.archived,
organization.trial,
organization.system_admin,
organization.created_at,
organization.updated_at,
COUNT(DISTINCT project.id) AS projects,
COUNT(DISTINCT environment_v2.id) AS environments,
COUNT(DISTINCT account_v2.email) AS users
FROM
organization
LEFT JOIN project ON organization.id = project.organization_id
LEFT JOIN environment_v2 ON organization.id = environment_v2.organization_id
LEFT JOIN account_v2 ON organization.id = account_v2.organization_id
WHERE
id = ?
organization.id = ?
GROUP BY
organization.id,
organization.name,
organization.owner_email,
organization.url_code,
organization.description,
organization.disabled,
organization.archived,
organization.trial,
organization.system_admin,
organization.created_at,
organization.updated_at