Skip to content

Commit

Permalink
FixingSVX version info when generating scenes (manual)
Browse files Browse the repository at this point in the history
(new) AssetVersion.fetchActiveVoyagerSceneFromScene gets SVX scene attached to current version
(fix) using latest Voyager release
(fix) removed obsolete Asset.fetchVoyagerSceneFromScene
  • Loading branch information
EMaslowskiQ committed Sep 9, 2024
1 parent 5bef625 commit 48bc2df
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function DetailsThumbnail(props: DetailsThumbnailProps): React.ReactElement {
document.head.appendChild(css);

const script = document.createElement('script');
script.src = 'https://www.egofarms.com/temp/voyager-story-test.min.js'; //TODO: replace with config once bug fix applied: Config.voyager.storyJS;
script.src = Config.voyager.storyJS;
script.async = true;
document.body.appendChild(script);

Expand Down
14 changes: 0 additions & 14 deletions server/db/api/Asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,6 @@ export class Asset extends DBC.DBObject<AssetBase> implements AssetBase, SystemO
`,Asset);
}

static async fetchVoyagerSceneFromScene(idScene: number): Promise<Asset[] | null> {
// get the voyager scene asset associated with the Packrat scene (if any)
// TODO: get asset type id from VocabularyID
const idvAssetType: number = 137;

return DBC.CopyArray<AssetBase, Asset>(
await DBC.DBConnection.prisma.$queryRaw<Asset[]>`
SELECT a.* FROM Scene AS scn
JOIN SystemObject AS scnSO ON scn.idScene = scnSO.idScene
JOIN Asset AS a ON a.idSystemObject = scnSO.idSystemObject
WHERE scn.idScene = ${idScene} AND a.idVAssetType = ${idvAssetType};
`,Asset);
}

/** Fetches assets that are connected to the specified idSystemObject (via that object's last SystemObjectVersion,
* and that SystemObjectVersionAssetVersionXref's records). For those assets, we look for a match on FileName, idVAssetType */
static async fetchMatching(idSystemObject: number, FileName: string, idVAssetType: number): Promise<Asset | null> {
Expand Down
24 changes: 24 additions & 0 deletions server/db/api/AssetVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,30 @@ export class AssetVersion extends DBC.DBObject<AssetVersionBase> implements Asse
}
}

/** Fetches the the active asset version that is being used by the given scene for Voyager SVX scene */
static async fetchActiveVoyagerSceneFromScene(idScene: number): Promise<AssetVersion | null> {
try {
// get the (active) voyager scene asset associated with the Packrat scene (if any)
// TODO: get asset type id from VocabularyID
const idvAssetType: number = 137;
const assetVersion: AssetVersion[] | null = DBC.CopyArray<AssetVersionBase, AssetVersion>(
await DBC.DBConnection.prisma.$queryRaw<AssetVersion[]>`
SELECT * FROM Scene AS scn
JOIN SystemObject AS scnSO ON (scnSO.idScene=scn.idScene)
JOIN SystemObjectVersion AS scnSOV ON (scnSOV.idSystemObject=scnSO.idSystemObject)
JOIN SystemObjectVersionAssetVersionXref as sovAssetXref ON (sovAssetXref.idSystemObjectVersion=scnSOV.idSystemObjectVersion)
JOIN AssetVersion AS av ON (av.idAssetVersion=sovAssetXref.idAssetVersion)
JOIN Asset AS a ON (a.idAsset=av.idAsset AND a.idVAssetType=${idvAssetType})
WHERE scn.idScene=${idScene}
ORDER BY scnSOV.DateCreated DESC
LIMIT 1`,AssetVersion);
return (!assetVersion || assetVersion.length===0) ? null : assetVersion[0];
} catch (error) /* istanbul ignore next */ {
LOG.error('DBAPI.AssetVersion.fetchVoyagerSceneFromScene', LOG.LS.eDB, error);
return null;
}
}

static async fetchFromUser(idUserCreator: number): Promise<AssetVersion[] | null> {
if (!idUserCreator)
return null;
Expand Down
49 changes: 20 additions & 29 deletions server/workflow/impl/Packrat/WorkflowEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ export class WorkflowEngine implements WF.IWorkflowEngine {
async generateScene(idModel: number, idScene: number | null, workflowParams: WF.WorkflowParameters): Promise<WF.WorkflowCreateResult> {
LOG.info(`WorkflowEngine.generateScene (idModel: ${idModel} | idScene: ${idScene} | params: ${H.Helpers.JSONStringify(workflowParams)})`,LOG.LS.eDEBUG);

// making sure we didn't make it here but user wanted to skip generation
// if (workflowParams.parameters.skipSceneGenerate===true) {
// LOG.info(`WorkflowEngine.eventIngestionIngestObjectModel skipping si-voyager-scene per user instruction (idModel: ${idModel} | idSO: ${workflowParams.idSystemObject})`, LOG.LS.eWF);
// return { success: false, message: 'skipped generating scene per user request', data: { isValid: false } };
// }

//#region check for duplicate jobs
// make sure we don't have any jobs running. >0 if a running job was found.
const activeJobs: DBAPI.JobRun[] | null = await DBAPI.JobRun.fetchActiveByModel(8,idModel);
Expand Down Expand Up @@ -378,20 +384,12 @@ export class WorkflowEngine implements WF.IWorkflowEngine {
return { success: false, message: 'cannot get model Asset', data: { isValid: false } };
const modelAsset: DBAPI.Asset = modelAssets[0];

// get our asset and version used by the model
// const { success, asset, assetVersion } = await this.computeAssetAndVersion(modelSO.idSystemObject);
// if (!success || !asset || !assetVersion || !asset.idSystemObject) {
// LOG.error(`WorkflowEngine.generateScene cannot get model asset and version (idModel: ${idModel} | idSystemObject: ${modelSO.idSystemObject})`, LOG.LS.eDB);
// return { success: false, message: 'cannot get model asset and version', data: { isValid: false } };
// }

// get model info
const CMIR: ComputeModelInfoResult | undefined = await this.computeModelInfo(idModel, modelAsset.idSystemObject ?? -1);
if (!CMIR || CMIR.exitEarly || CMIR.assetVersionGeometry === undefined) {
LOG.error(`WorkflowEngine.generateScene cannot compute model info (idModel: ${idModel} | CMIR: ${H.Helpers.JSONStringify(CMIR)})`, LOG.LS.eWF);
return { success: false, message: 'cannot get model info', data: { isValid: false } };
}
// console.log(H.Helpers.JSONStringify(CMIR));

// bail if no units defined
if(CMIR.units ===undefined) {
Expand Down Expand Up @@ -423,9 +421,6 @@ export class WorkflowEngine implements WF.IWorkflowEngine {

//#region scene
// if we have a scene get it and a reference to the SVX so it can be fed in as a parameter
// TODO: if no scene then we need to create one for this Model and hook it up
// TODO: determine if we have an SVX file that is of different basename and bail/fix it
// so it passes validation when returned from Cook.
let scene: DBAPI.Scene | null = null;

// if we received an id for the scene, use it
Expand All @@ -452,27 +447,23 @@ export class WorkflowEngine implements WF.IWorkflowEngine {
// if we don't have a scene then the model may have just been ingested
const svxFilename: string = sceneBaseName + '.svx.json';
if(scene) {
// get SVX from the scene
const svxAsset: DBAPI.Asset[] | null = await DBAPI.Asset.fetchVoyagerSceneFromScene(scene.idScene);
if(!svxAsset || svxAsset.length===0)
console.log(`No SVX found for scene ${scene.idScene} (idModel: ${idModel})`);
// get the asset version for the active voyager scene. only returns the most recent and does not support
// multiple SVX files for a single scene
const svxAssetVersion: DBAPI.AssetVersion | null = await DBAPI.AssetVersion.fetchActiveVoyagerSceneFromScene(scene.idScene);
if(!svxAssetVersion)
LOG.info(`WorkflowEngine.generateScene no active SVX file found for scene ${scene.idScene} (idModel: ${idModel})`,LOG.LS.eWF);
else {
// compare filenames. if a match then add it to staged resources. otherwise, fail
if(svxAsset[0].FileName !== svxFilename)
console.log(`basenames do not match. (${svxAsset[0].FileName} -> ${svxFilename})`);
// TODO: fix the naming?
if(svxAssetVersion.FileName !== svxFilename)
LOG.info(`WorkflowEngine.generateScene basenames do not match. (${svxAssetVersion.FileName} -> ${svxFilename})`,LOG.LS.eWF);
else {
// get our last version
const svxAssetVersion: DBAPI.AssetVersion | null = await DBAPI.AssetVersion.fetchLatestFromAsset(svxAsset[0].idAsset);
if(!svxAssetVersion)
console.log(`cannot get AssetVersion. (${svxAsset[0].idAsset})`);
else {
// grab our SystemObject since we need to feed it to the list of staged files
const svxAssetVersionSO: DBAPI.SystemObject | null = await svxAssetVersion.fetchSystemObject();
if(!svxAssetVersionSO)
console.log(`cannot get SystemObject for asset version. (idAssetVersion: ${svxAssetVersion.idAssetVersion})`);
else
idSystemObjects.push(svxAssetVersionSO.idSystemObject);
}
// grab our SystemObject since we need to feed it to the list of staged files
const svxAssetVersionSO: DBAPI.SystemObject | null = await svxAssetVersion.fetchSystemObject();
if(!svxAssetVersionSO)
LOG.info(`WorkflowEngine.generateScene cannot get SystemObject for asset version. (idAssetVersion: ${svxAssetVersion.idAssetVersion})`,LOG.LS.eWF);
else
idSystemObjects.push(svxAssetVersionSO.idSystemObject);
}
}
}
Expand Down

0 comments on commit 48bc2df

Please sign in to comment.