Skip to content

Commit

Permalink
Merge pull request #19 from asad-rafter/CLD-303-job-last-execution-date
Browse files Browse the repository at this point in the history
added a logger for last execution date
  • Loading branch information
yuval-cloudinary committed Jun 24, 2024
2 parents a6fc4a7 + 1cf0a8a commit 02052e4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,12 @@ module.exports.Start = function (args) {
cloudinaryUrlFileWriter.close();

Transaction.wrap(function () {
Site.current.preferences.custom.CLDImportImageAndAltTextjobLastExecutionTime = params.currentExecutionTime;
currentSite.preferences.custom.CLDImportImageAndAltTextjobLastExecutionTime = params.currentExecutionTime;
});
var CLDImportImageAndAltTextjobLastExecutionTime = currentSite.preferences.custom.CLDImportImageAndAltTextjobLastExecutionTime ? currentSite.preferences.custom.CLDImportImageAndAltTextjobLastExecutionTime.toString() : currentSite.preferences.custom.CLDImportImageAndAltTextjobLastExecutionTime;
if (params.currentExecutionTime.toString() !== CLDImportImageAndAltTextjobLastExecutionTime) {
jobLogger.warn(' Unable to update the job last execution timestamp in Custom Preferences->Cloudinary Jobs Configurations field: Update Product Feeds Job Last Execution Date : {0}', params.currentExecutionTime.toString());
}
} catch (e) {
jobLogger.error('Error occured while processing folder/file, message : {0}', e.message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,15 @@ module.exports.Start = function (args) {
}
}

var runTime = new Date();
const currentSite = Site.getCurrent();
Transaction.wrap(function () {
var runTime = new Date();
Site.current.preferences.custom.CLDCatalogContentJobLastExecutionDate = runTime;
currentSite.preferences.custom.CLDCatalogContentJobLastExecutionDate = runTime;
});
var CLDCatalogContentJobLastExecutionDate = currentSite.preferences.custom.CLDCatalogContentJobLastExecutionDate ? currentSite.preferences.custom.CLDCatalogContentJobLastExecutionDate.toString() : currentSite.preferences.custom.CLDCatalogContentJobLastExecutionDate;
if (runTime.toString() !== CLDCatalogContentJobLastExecutionDate) {
jobLogger.warn(' Unable to update the job last execution timestamp in Custom Preferences->Cloudinary Jobs Configurations field: Catalog Content Job Last Execution Date : {0}', runTime.toString());
}
} catch (e) {
jobLogger.error('Error occured while processing catalog content folder/file, message : {0}', e.message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ module.exports.Start = function (args) {
continue;
}

assetPublicID = jobStepHelpers.getAssetRelURL(args.file.toString());
const file = args && args.file ? args.file.toString() : '';
assetPublicID = jobStepHelpers.getAssetRelURL(file);

// if job is running in "delta" mode, check the last modification date on the file
if (syncMode === cloudinaryConstants.SYNC_MODE_DELTA) {
Expand Down Expand Up @@ -130,10 +131,14 @@ module.exports.Start = function (args) {
}
}

var runTime = new Date();
Transaction.wrap(function () {
var runTime = new Date();
currentSite.preferences.custom.CLDContentLibraryJobLastExecutionDate = runTime;
});
var CLDContentLibraryJobLastExecutionDate = currentSite.preferences.custom.CLDContentLibraryJobLastExecutionDate ? currentSite.preferences.custom.CLDContentLibraryJobLastExecutionDate.toString() : currentSite.preferences.custom.CLDContentLibraryJobLastExecutionDate;
if (runTime.toString() !== CLDContentLibraryJobLastExecutionDate) {
jobLogger.warn(' Unable to update the job last execution timestamp in Custom Preferences->Cloudinary Jobs Configurations field: Content Library Job Last Execution Date : {0}', runTime.toString());
}
} catch (e) {
jobLogger.error('Error occured while processing library content folder/file, message : {0}', e.message);
}
Expand Down

0 comments on commit 02052e4

Please sign in to comment.