Skip to content

Commit

Permalink
query fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Uroš Marolt committed Jan 8, 2024
1 parent 8f8b6d9 commit 978a6f3
Showing 1 changed file with 14 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,19 @@ export class TenantRepository extends RepositoryBase<TenantRepository> {
}

async getPremiumTenants(perPage: number, lastId?: string): Promise<IPremiumTenantInfo[]> {
if (lastId) {
return await this.db().any(
`
select id,
plan
from tenants
where plan in ($(plans:csv)) and id > $(lastId)
order by id
limit ${perPage};
`,
{
plans: [TenantPlans.Enterprise, TenantPlans.Growth, TenantPlans.Scale],
lastId,
},
)
} else {
return await this.db().any(
`
select id,
plan
from tenants
where plan in ($(plans:csv))
order by id
limit ${perPage};
`,
{
plans: [TenantPlans.Enterprise, TenantPlans.Growth, TenantPlans.Scale],
},
)
}
return await this.db().any(
`
select id,
plan
from tenants
where plan in ($(plans:csv)) ${lastId ? 'and id > $(lastId)' : ''}
order by id
limit ${perPage};
`,
{
plans: [TenantPlans.Enterprise, TenantPlans.Growth, TenantPlans.Scale],
lastId,
},
)
}
}

0 comments on commit 978a6f3

Please sign in to comment.