Added processing tag/user import measurements
MODIFY
src/scheduler/tasks/ImportTagsTask.ts
src/scheduler/tasks/ImportTagsTask.ts
@@ -27,8 +27,17 @@ export default class ImportTagsTask extends SchedulerTask {
inError: 0,
inSuccess: 0,
};
+ const startTime = new Date().getTime();
// Get total number of Tags to import
const totalTagsToImport = await TagStorage.getImportedTagsCount(tenant.id);
+ if (totalTagsToImport > 0) {
+ await Logging.logDebug({
+ tenantID: tenant.id,
+ action: ServerAction.IMPORT_TAGS,
+ module: MODULE_NAME, method: 'processTenant',
+ message: `${totalTagsToImport} Tag(s) are going to be imported...`
+ });
+ }
do {
// Get the imported tags
importedTags = await TagStorage.getImportedTags(tenant.id, { status: ImportStatus.READY }, dbParams);
@@ -78,20 +87,22 @@ export default class ImportTagsTask extends SchedulerTask {
}
// Log
if (importedTags.result.length > 0 && (result.inError + result.inSuccess) > 0) {
+ const intermediateDurationSecs = Math.round((new Date().getTime() - startTime) / 1000);
await Logging.logDebug({
tenantID: tenant.id,
action: ServerAction.IMPORT_TAGS,
module: MODULE_NAME, method: 'processTenant',
- message: `${result.inError + result.inSuccess}/${totalTagsToImport} Tag(s) have been processed`
+ message: `${result.inError + result.inSuccess}/${totalTagsToImport} Tag(s) have been processed in ${intermediateDurationSecs}s...`
});
}
} while (!Utils.isEmptyArray(importedTags?.result));
// Log final results
+ const executionDurationSecs = Math.round((new Date().getTime() - startTime) / 1000);
await Logging.logActionsResponse(tenant.id, ServerAction.IMPORT_TAGS, MODULE_NAME, 'processTenant', result,
- `{{inSuccess}} Tag(s) have been imported successfully in Tenant ${Utils.buildTenantName(tenant)}`,
- `{{inError}} Tag(s) failed to be imported in Tenant ${Utils.buildTenantName(tenant)}`,
- `{{inSuccess}} Tag(s) have been imported successfully but {{inError}} failed in Tenant ${Utils.buildTenantName(tenant)}`,
- `Not Tag has been imported in Tenant ${Utils.buildTenantName(tenant)}`
+ `{{inSuccess}} Tag(s) have been imported successfully in ${executionDurationSecs}s in Tenant ${Utils.buildTenantName(tenant)}`,
+ `{{inError}} Tag(s) failed to be imported in ${executionDurationSecs}s in Tenant ${Utils.buildTenantName(tenant)}`,
+ `{{inSuccess}} Tag(s) have been imported successfully but {{inError}} failed in ${executionDurationSecs}s in Tenant ${Utils.buildTenantName(tenant)}`,
+ `Not Tag has been imported in ${executionDurationSecs}s in Tenant ${Utils.buildTenantName(tenant)}`
);
} catch (error) {
// Log error

MODIFY
src/scheduler/tasks/ImportUsersTask.ts
src/scheduler/tasks/ImportUsersTask.ts
@@ -27,8 +27,17 @@ export default class ImportUsersTask extends SchedulerTask {
inError: 0,
inSuccess: 0,
};
+ const startTime = new Date().getTime();
// Get total number of Users to import
const totalUsersToImport = await UserStorage.getImportedUsersCount(tenant.id);
+ if (totalUsersToImport > 0) {
+ await Logging.logDebug({
+ tenantID: tenant.id,
+ action: ServerAction.IMPORT_USERS,
+ module: MODULE_NAME, method: 'processTenant',
+ message: `${totalUsersToImport} User(s) are going to be imported...`
+ });
+ }
do {
// Get the imported users
importedUsers = await UserStorage.getImportedUsers(tenant.id, { status: ImportStatus.READY }, dbParams);
@@ -87,20 +96,22 @@ export default class ImportUsersTask extends SchedulerTask {
}
// Log
if (importedUsers.result.length > 0 && (result.inError + result.inSuccess) > 0) {
+ const intermediateDurationSecs = Math.round((new Date().getTime() - startTime) / 1000);
await Logging.logDebug({
tenantID: tenant.id,
action: ServerAction.IMPORT_USERS,
module: MODULE_NAME, method: 'processTenant',
- message: `${result.inError + result.inSuccess}/${totalUsersToImport} User(s) have been processed`
+ message: `${result.inError + result.inSuccess}/${totalUsersToImport} User(s) have been processed in ${intermediateDurationSecs}s...`
});
}
} while (!Utils.isEmptyArray(importedUsers?.result));
// Log final results
+ const executionDurationSecs = Math.round((new Date().getTime() - startTime) / 1000);
await Logging.logActionsResponse(tenant.id, ServerAction.IMPORT_USERS, MODULE_NAME, 'processTenant', result,
- `{{inSuccess}} User(s) have been imported successfully in Tenant ${Utils.buildTenantName(tenant)}`,
- `{{inError}} User(s) failed to be imported in Tenant ${Utils.buildTenantName(tenant)}`,
- `{{inSuccess}} User(s) have been imported successfully but {{inError}} failed in Tenant ${Utils.buildTenantName(tenant)}`,
- `Not User has been imported in Tenant ${Utils.buildTenantName(tenant)}`
+ `{{inSuccess}} User(s) have been imported successfully in ${executionDurationSecs}s in Tenant ${Utils.buildTenantName(tenant)}`,
+ `{{inError}} User(s) failed to be imported in ${executionDurationSecs}s in Tenant ${Utils.buildTenantName(tenant)}`,
+ `{{inSuccess}} User(s) have been imported successfully but {{inError}} failed in ${executionDurationSecs}s in Tenant ${Utils.buildTenantName(tenant)}`,
+ `Not User has been imported in ${executionDurationSecs}s in Tenant ${Utils.buildTenantName(tenant)}`
);
} catch (error) {
// Log error

MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -492,6 +492,7 @@ export default class TagService {
const importedBy = req.user.id;
const importedOn = new Date();
const tagsToBeImported: ImportedTag[] = [];
+ const startTime = new Date().getTime();
const result: ActionsResponse = {
inSuccess: 0,
inError: 0
@@ -610,13 +611,14 @@ export default class TagService {
});
// eslint-disable-next-line @typescript-eslint/no-misused-promises
busboy.on('finish', async () => {
+ const executionDurationSecs = Utils.truncTo((new Date().getTime() - startTime) / 1000, 2);
await Logging.logActionsResponse(
req.user.tenantID, action,
MODULE_NAME, 'handleImportTags', result,
- '{{inSuccess}} Tag(s) were successfully uploaded and ready for asynchronous import',
- '{{inError}} Tag(s) failed to be uploaded',
- '{{inSuccess}} Tag(s) were successfully uploaded and ready for asynchronous import and {{inError}} failed to be uploaded',
- 'No Tag have been uploaded', req.user
+ `{{inSuccess}} Tag(s) were successfully uploaded in ${executionDurationSecs}s and ready for asynchronous import`,
+ `{{inError}} Tag(s) failed to be uploaded in ${executionDurationSecs}s`,
+ `{{inSuccess}} Tag(s) were successfully uploaded in ${executionDurationSecs}s and ready for asynchronous import and {{inError}} failed to be uploaded`,
+ `No Tag have been uploaded in ${executionDurationSecs}s`, req.user
);
// Insert batched
if (tagsToBeImported.length > 0) {

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -891,6 +891,7 @@ export default class UserService {
const importedBy = req.user.id;
const importedOn = new Date();
const usersToBeImported: ImportedUser[] = [];
+ const startTime = new Date().getTime();
const result: ActionsResponse = {
inSuccess: 0,
inError: 0
@@ -1008,13 +1009,14 @@ export default class UserService {
});
// eslint-disable-next-line @typescript-eslint/no-misused-promises
busboy.on('finish', async () => {
+ const executionDurationSecs = Utils.truncTo((new Date().getTime() - startTime) / 1000, 2);
await Logging.logActionsResponse(
req.user.tenantID, action,
MODULE_NAME, 'handleImportUsers', result,
- '{{inSuccess}} User(s) were successfully uploaded and ready for asynchronous import',
- '{{inError}} User(s) failed to be uploaded',
- '{{inSuccess}} User(s) were successfully uploaded and ready for asynchronous import and {{inError}} failed to be uploaded',
- 'No User have been uploaded', req.user
+ `{{inSuccess}} User(s) were successfully uploaded in ${executionDurationSecs}s and ready for asynchronous import`,
+ `{{inError}} User(s) failed to be uploaded in ${executionDurationSecs}s`,
+ `{{inSuccess}} User(s) were successfully uploaded in ${executionDurationSecs}s and ready for asynchronous import and {{inError}} failed to be uploaded`,
+ `No User have been uploaded in ${executionDurationSecs}s`, req.user
);
// Insert batched
if (usersToBeImported.length > 0) {

Added processing tag/user import measurements