Allow getting team websites.

This commit is contained in:
Mike Cao 2025-09-12 08:21:29 -07:00
parent e610de383a
commit 433ce98719
10 changed files with 79 additions and 56 deletions

View file

@ -46,46 +46,34 @@ export async function getWebsites(
return pagedQuery('website', { ...criteria, where }, filters);
}
export async function getAllWebsites(userId: string) {
return prisma.client.website.findMany({
where: {
OR: [
{ userId },
{
team: {
deletedAt: null,
teamUser: {
some: {
userId,
export async function getAllUserWebsitesIncludingTeamOwner(
userId: string,
filters?: QueryFilters,
): Promise<PageResult<Website[]>> {
return getWebsites(
{
where: {
OR: [
{ userId },
{
team: {
deletedAt: null,
members: {
some: {
role: ROLES.teamOwner,
userId,
},
},
},
},
},
],
deletedAt: null,
],
},
},
});
}
export async function getAllUserWebsitesIncludingTeamOwner(userId: string) {
return prisma.client.website.findMany({
where: {
OR: [
{ userId },
{
team: {
deletedAt: null,
teamUser: {
some: {
role: ROLES.teamOwner,
userId,
},
},
},
},
],
{
orderBy: 'name',
...filters,
},
});
);
}
export async function getUserWebsites(

View file

@ -58,7 +58,7 @@ async function relationalQuery(
) as t
`,
queryParams,
);
).then(result => result?.[0]);
}
async function clickhouseQuery(