Skip to content

Commit

Permalink
add plan to unleash context
Browse files Browse the repository at this point in the history
  • Loading branch information
epipav committed Jan 4, 2024
1 parent 3154242 commit 63212c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ITenantId } from 'types'
import { ITenant } from 'types'
import { svc } from '../main'
import TenantRepository from 'repo/tenant.repo'
import { isFeatureEnabled } from '@crowd/feature-flags'
import { FeatureFlag } from '@crowd/types'

export async function getAllTenants(): Promise<ITenantId[]> {
export async function getAllTenants(): Promise<ITenant[]> {
const tenantRepository = new TenantRepository(svc.postgres.writer.connection(), svc.log)
const tenants = await tenantRepository.getAllTenants()

Expand All @@ -15,6 +15,7 @@ export async function getAllTenants(): Promise<ITenantId[]> {
async () => {
return {
tenantId: tenant.tenantId,
plan: tenant.plan,
}
},
svc.unleash,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { DbConnection, DbTransaction } from '@crowd/database'
import { Logger } from '@crowd/logging'
import { ITenantId } from 'types'
import { ITenant } from 'types'

class TenantRepository {
constructor(
private readonly connection: DbConnection | DbTransaction,
private readonly log: Logger,
) {}

async getAllTenants(): Promise<ITenantId[]> {
let rows: ITenantId[] = []
async getAllTenants(): Promise<ITenant[]> {
let rows: ITenant[] = []
try {
rows = await this.connection.query(`
SELECT id as "tenantId"
SELECT id as "tenantId", plan
FROM tenants WHERE "deletedAt" IS NULL;
`)
} catch (err) {
Expand Down
3 changes: 2 additions & 1 deletion services/apps/merge_suggestions_worker/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface ITenantId {
export interface ITenant {
tenantId: string
plan: string
}

interface ITermFilter {
Expand Down

0 comments on commit 63212c0

Please sign in to comment.