mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-26 10:43:09 +00:00
Fix pr blueprints not picking up site
This commit is contained in:
@@ -131,42 +131,23 @@ export async function updateClientResources(
|
|||||||
: [];
|
: [];
|
||||||
|
|
||||||
const allSites: { siteId: number }[] = [];
|
const allSites: { siteId: number }[] = [];
|
||||||
if (resourceData.site) {
|
|
||||||
let siteSingle;
|
|
||||||
const resourceSiteId = resourceData.site;
|
|
||||||
|
|
||||||
if (resourceSiteId) {
|
if (resourceData.site) {
|
||||||
// Look up site by niceId
|
// Look up site by niceId
|
||||||
[siteSingle] = await trx
|
const [siteSingle] = await trx
|
||||||
.select({ siteId: sites.siteId })
|
.select({ siteId: sites.siteId })
|
||||||
.from(sites)
|
.from(sites)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(sites.niceId, resourceSiteId),
|
eq(sites.niceId, resourceData.site),
|
||||||
eq(sites.orgId, orgId)
|
eq(sites.orgId, orgId)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
} else if (siteId) {
|
if (siteSingle) {
|
||||||
// Use the provided siteId directly, but verify it belongs to the org
|
|
||||||
[siteSingle] = await trx
|
|
||||||
.select({ siteId: sites.siteId })
|
|
||||||
.from(sites)
|
|
||||||
.where(
|
|
||||||
and(eq(sites.siteId, siteId), eq(sites.orgId, orgId))
|
|
||||||
)
|
|
||||||
.limit(1);
|
|
||||||
} else {
|
|
||||||
throw new Error(`Target site is required`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!siteSingle) {
|
|
||||||
throw new Error(
|
|
||||||
`Site not found: ${resourceSiteId} in org ${orgId}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
allSites.push(siteSingle);
|
allSites.push(siteSingle);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (resourceData.sites) {
|
if (resourceData.sites) {
|
||||||
for (const siteNiceId of resourceData.sites) {
|
for (const siteNiceId of resourceData.sites) {
|
||||||
@@ -180,14 +161,30 @@ export async function updateClientResources(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
if (!site) {
|
if (site) {
|
||||||
throw new Error(
|
|
||||||
`Site not found: ${siteId} in org ${orgId}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
allSites.push(site);
|
allSites.push(site);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (siteId && allSites.length === 0) {
|
||||||
|
// only add if there are not provided sites
|
||||||
|
// Use the provided siteId directly, but verify it belongs to the org
|
||||||
|
const [siteSingle] = await trx
|
||||||
|
.select({ siteId: sites.siteId })
|
||||||
|
.from(sites)
|
||||||
|
.where(and(eq(sites.siteId, siteId), eq(sites.orgId, orgId)))
|
||||||
|
.limit(1);
|
||||||
|
if (siteSingle) {
|
||||||
|
allSites.push(siteSingle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allSites.length === 0) {
|
||||||
|
throw new Error(
|
||||||
|
`No valid sites found for private private resource ${resourceNiceId} in org ${orgId}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (existingResource) {
|
if (existingResource) {
|
||||||
let domainInfo:
|
let domainInfo:
|
||||||
|
|||||||
Reference in New Issue
Block a user