-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tenant setting and blank screen (#1920)
- Loading branch information
1 parent
d354fc8
commit 42d756c
Showing
3 changed files
with
47 additions
and
16 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,10 +1,42 @@ | ||
import { Error403 } from '@crowd/common' | ||
import { RedisCache } from '@crowd/redis' | ||
import { FeatureFlagRedisKey } from '@crowd/types' | ||
import AutomationRepository from '@/database/repositories/automationRepository' | ||
|
||
export default async (req, res) => { | ||
if (!req.currentUser || !req.currentUser.id) { | ||
await req.responseHandler.error(req, res, new Error403(req.language)) | ||
return | ||
} | ||
|
||
await req.responseHandler.success(req, res, req.currentUser) | ||
const payload = req.currentUser | ||
|
||
const csvExportCountCache = new RedisCache( | ||
FeatureFlagRedisKey.CSV_EXPORT_COUNT, | ||
req.redis, | ||
req.log, | ||
) | ||
|
||
const memberEnrichmentCountCache = new RedisCache( | ||
FeatureFlagRedisKey.MEMBER_ENRICHMENT_COUNT, | ||
req.redis, | ||
req.log, | ||
) | ||
|
||
payload.tenants = await Promise.all( | ||
payload.tenants.map(async (tenantUser) => { | ||
tenantUser.tenant.dataValues = { | ||
...tenantUser.tenant.dataValues, | ||
csvExportCount: Number(await csvExportCountCache.get(tenantUser.tenant.id)) || 0, | ||
automationCount: | ||
Number(await AutomationRepository.countAllActive(req.database, tenantUser.tenant.id)) || | ||
0, | ||
memberEnrichmentCount: | ||
Number(await memberEnrichmentCountCache.get(tenantUser.tenant.id)) || 0, | ||
} | ||
return tenantUser | ||
}), | ||
) | ||
|
||
await req.responseHandler.success(req, res, payload) | ||
} |
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