Refactored SynchronizeTagsImportTask coding
MODIFY
src/migration/tasks/AddUserInTransactionsTask.ts
src/migration/tasks/AddUserInTransactionsTask.ts
@@ -30,7 +30,7 @@ export default class AddUserInTransactionsTask extends MigrationTask {
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `${transactionsMDB.length} Transaction(s) are going to be assigned an user in Tenant '${tenant.name}' ('${tenant.subdomain}')...`,
+ message: `${transactionsMDB.length} Transaction(s) are going to be assigned an user in Tenant ${Utils.buildTenantName(tenant)}...`,
});
for (const transactionMDB of transactionsMDB) {
// Get the user with tag
@@ -56,7 +56,7 @@ export default class AddUserInTransactionsTask extends MigrationTask {
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `${success} Transaction(s) have been assigned an user in Tenant '${tenant.name}' ('${tenant.subdomain}')...`,
+ message: `${success} Transaction(s) have been assigned an user in Tenant ${Utils.buildTenantName(tenant)})...`,
});
}
}

MODIFY
src/migration/tasks/CleanupMeterValuesTask.ts
src/migration/tasks/CleanupMeterValuesTask.ts
@@ -56,7 +56,7 @@ export default class CleanupMeterValuesTask extends MigrationTask {
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrate',
- message: `Tenant ${tenant.name} (${tenant.id}): ${meterValuesMDB.length} orphan Meter Values have been deleted`
+ message: `Tenant ${Utils.buildTenantName(tenant)} (${tenant.id}): ${meterValuesMDB.length} orphan Meter Values have been deleted`
});
}
}

MODIFY
src/migration/tasks/DeleteChargingStationPropertiesTask.ts
src/migration/tasks/DeleteChargingStationPropertiesTask.ts
@@ -29,7 +29,7 @@ export default class DeleteChargingStationPropertiesTask extends MigrationTask {
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `${result.modifiedCount} Charging Stations' properties have been deleted in Tenant '${tenant.name}' ('${tenant.subdomain}')`
+ message: `${result.modifiedCount} Charging Stations' properties have been deleted in Tenant ${Utils.buildTenantName(tenant)})`
});
}
}

MODIFY
src/migration/tasks/RecomputeAllTransactionsConsumptionsTask.ts
src/migration/tasks/RecomputeAllTransactionsConsumptionsTask.ts
@@ -46,7 +46,7 @@ export default class RecomputeAllTransactionsConsumptionsTask extends MigrationT
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `${transactionsMDB.length} Transaction(s) are going to be recomputed in Tenant '${tenant.name}' ('${tenant.subdomain}')...`,
+ message: `${transactionsMDB.length} Transaction(s) are going to be recomputed in Tenant ${Utils.buildTenantName(tenant)})...`,
});
await Promise.map(transactionsMDB, async (transactionMDB) => {
try {
@@ -63,7 +63,7 @@ export default class RecomputeAllTransactionsConsumptionsTask extends MigrationT
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `> ${consumptionsUpdated.inError + consumptionsUpdated.inSuccess}/${transactionsMDB.length} - Processed Transaction ID '${transactionMDB._id}' with ${nbrOfConsumptions} consumptions in ${durationSecs}s in Tenant '${tenant.name}' ('${tenant.subdomain}')`,
+ message: `> ${consumptionsUpdated.inError + consumptionsUpdated.inSuccess}/${transactionsMDB.length} - Processed Transaction ID '${transactionMDB._id}' with ${nbrOfConsumptions} consumptions in ${durationSecs}s in Tenant ${Utils.buildTenantName(tenant)})`,
});
} else {
// Delete transaction
@@ -72,7 +72,7 @@ export default class RecomputeAllTransactionsConsumptionsTask extends MigrationT
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `> ${consumptionsUpdated.inError + consumptionsUpdated.inSuccess}/${transactionsMDB.length} - Deleted Transaction ID '${transactionMDB._id}' with no consumption in Tenant '${tenant.name}' ('${tenant.subdomain}')`,
+ message: `> ${consumptionsUpdated.inError + consumptionsUpdated.inSuccess}/${transactionsMDB.length} - Deleted Transaction ID '${transactionMDB._id}' with no consumption in Tenant ${Utils.buildTenantName(tenant)})`,
});
}
} catch (error) {
@@ -81,7 +81,7 @@ export default class RecomputeAllTransactionsConsumptionsTask extends MigrationT
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `> ${consumptionsUpdated.inError + consumptionsUpdated.inSuccess}/${transactionsMDB.length} - Cannot recompute the consumptions of Transaction ID '${transactionMDB._id}' in Tenant '${tenant.name}' ('${tenant.subdomain}')`,
+ message: `> ${consumptionsUpdated.inError + consumptionsUpdated.inSuccess}/${transactionsMDB.length} - Cannot recompute the consumptions of Transaction ID '${transactionMDB._id}' in Tenant ${Utils.buildTenantName(tenant)})`,
detailedMessages: { error: error.message, stack: error.stack }
});
}
@@ -90,10 +90,10 @@ export default class RecomputeAllTransactionsConsumptionsTask extends MigrationT
// Log in the default tenant
void Logging.logActionsResponse(Constants.DEFAULT_TENANT, ServerAction.MIGRATION,
MODULE_NAME, 'migrateTenant', consumptionsUpdated,
- `{{inSuccess}} transaction(s) were successfully processed in ${totalDurationSecs} secs in Tenant '${tenant.name}' ('${tenant.subdomain}')`,
- `{{inError}} transaction(s) failed to be processed in ${totalDurationSecs} secs in Tenant '${tenant.name}' ('${tenant.subdomain}')`,
- `{{inSuccess}} transaction(s) were successfully processed in ${totalDurationSecs} secs and {{inError}} failed to be processed in Tenant '${tenant.name}' ('${tenant.subdomain}')`,
- `All the transactions are up to date in Tenant '${tenant.name}' ('${tenant.subdomain}')`
+ `{{inSuccess}} transaction(s) were successfully processed in ${totalDurationSecs} secs in Tenant ${Utils.buildTenantName(tenant)})`,
+ `{{inError}} transaction(s) failed to be processed in ${totalDurationSecs} secs in Tenant ${Utils.buildTenantName(tenant)})`,
+ `{{inSuccess}} transaction(s) were successfully processed in ${totalDurationSecs} secs and {{inError}} failed to be processed in Tenant ${Utils.buildTenantName(tenant)})`,
+ `All the transactions are up to date in Tenant ${Utils.buildTenantName(tenant)})`
);
});
}

MODIFY
src/migration/tasks/RecomputeAllTransactionsWithSimplePricingTask.ts
src/migration/tasks/RecomputeAllTransactionsWithSimplePricingTask.ts
@@ -46,7 +46,7 @@ export default class RecomputeAllTransactionsWithSimplePricingTask extends Migra
}
]).toArray();
if (transactionsMDB.length > 0) {
- let message = `${transactionsMDB.length} Transaction(s) are going to be recomputed in Tenant '${tenant.name}' ('${tenant.subdomain}')...`;
+ let message = `${transactionsMDB.length} Transaction(s) are going to be recomputed in Tenant ${Utils.buildTenantName(tenant)})...`;
await Logging.logInfo({
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
@@ -57,7 +57,7 @@ export default class RecomputeAllTransactionsWithSimplePricingTask extends Migra
await Promise.map(transactionsMDB, async (transactionMDB) => {
const numberOfProcessedTransactions = transactionsUpdated.inError + transactionsUpdated.inSuccess;
if (numberOfProcessedTransactions > 0 && (numberOfProcessedTransactions % 100) === 0) {
- message = `> ${transactionsUpdated.inError + transactionsUpdated.inSuccess}/${transactionsMDB.length} - Transaction consumptions recomputed in Tenant '${tenant.name}' ('${tenant.subdomain}')`;
+ message = `> ${transactionsUpdated.inError + transactionsUpdated.inSuccess}/${transactionsMDB.length} - Transaction consumptions recomputed in Tenant ${Utils.buildTenantName(tenant)})`;
await Logging.logDebug({
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
@@ -84,7 +84,7 @@ export default class RecomputeAllTransactionsWithSimplePricingTask extends Migra
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: TASK_NAME, method: 'migrateTenant',
- message: `> ${transactionsUpdated.inError + transactionsUpdated.inSuccess}/${transactionsMDB.length} - Cannot recompute the consumptions of Transaction ID '${transactionMDB._id}' in Tenant '${tenant.name}' ('${tenant.subdomain}')`,
+ message: `> ${transactionsUpdated.inError + transactionsUpdated.inSuccess}/${transactionsMDB.length} - Cannot recompute the consumptions of Transaction ID '${transactionMDB._id}' in Tenant ${Utils.buildTenantName(tenant)})`,
detailedMessages: { error: error.message, stack: error.stack }
});
}
@@ -93,10 +93,10 @@ export default class RecomputeAllTransactionsWithSimplePricingTask extends Migra
// Log in the default tenant
void Logging.logActionsResponse(Constants.DEFAULT_TENANT, ServerAction.MIGRATION,
TASK_NAME, 'migrateTenant', transactionsUpdated,
- `{{inSuccess}} transaction(s) were successfully processed in ${totalDurationSecs} secs in Tenant '${tenant.name}' ('${tenant.subdomain}')`,
- `{{inError}} transaction(s) failed to be processed in ${totalDurationSecs} secs in Tenant '${tenant.name}' ('${tenant.subdomain}')`,
- `{{inSuccess}} transaction(s) were successfully processed in ${totalDurationSecs} secs and {{inError}} failed to be processed in Tenant '${tenant.name}' ('${tenant.subdomain}')`,
- `All the transactions are up to date in Tenant '${tenant.name}' ('${tenant.subdomain}')`
+ `{{inSuccess}} transaction(s) were successfully processed in ${totalDurationSecs} secs in Tenant ${Utils.buildTenantName(tenant)})`,
+ `{{inError}} transaction(s) failed to be processed in ${totalDurationSecs} secs in Tenant ${Utils.buildTenantName(tenant)})`,
+ `{{inSuccess}} transaction(s) were successfully processed in ${totalDurationSecs} secs and {{inError}} failed to be processed in Tenant ${Utils.buildTenantName(tenant)})`,
+ `All the transactions are up to date in Tenant ${Utils.buildTenantName(tenant)})`
);
});
}

MODIFY
src/migration/tasks/RenameChargingStationPropertiesTask.ts
src/migration/tasks/RenameChargingStationPropertiesTask.ts
@@ -29,7 +29,7 @@ export default class RenameChargingStationPropertiesTask extends MigrationTask {
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `${result.modifiedCount} Charging Stations' properties have been updated in Tenant '${tenant.name}' ('${tenant.subdomain}')`
+ message: `${result.modifiedCount} Charging Stations' properties have been updated in Tenant ${Utils.buildTenantName(tenant)})`
});
}
}

MODIFY
src/migration/tasks/RenameSMTPAuthErrorTask.ts
src/migration/tasks/RenameSMTPAuthErrorTask.ts
@@ -30,7 +30,7 @@ export default class RenameSMTPAuthErrorTask extends MigrationTask {
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `${result.modifiedCount} Users' properties have been updated in Tenant '${tenant.name}' ('${tenant.subdomain}')`
+ message: `${result.modifiedCount} Users' properties have been updated in Tenant ${Utils.buildTenantName(tenant)})`
});
}
result = await global.database.getCollection<Notification>(tenant.id, 'notifications').updateMany(
@@ -48,7 +48,7 @@ export default class RenameSMTPAuthErrorTask extends MigrationTask {
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `${result.modifiedCount} Notifications' properties have been updated in Tenant '${tenant.name}' ('${tenant.subdomain}')`
+ message: `${result.modifiedCount} Notifications' properties have been updated in Tenant ${Utils.buildTenantName(tenant)})`
});
}
}

MODIFY
src/migration/tasks/RenameTransactionsAndConsumptionsTask.ts
src/migration/tasks/RenameTransactionsAndConsumptionsTask.ts
@@ -49,7 +49,7 @@ export default class RenameTransactionsAndConsumptionsTask extends MigrationTask
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'deleteConsumptionProperties',
- message: `${result.modifiedCount} Consumption(s) unused properties have been removed in Tenant '${tenant.name}' ('${tenant.subdomain}')`
+ message: `${result.modifiedCount} Consumption(s) unused properties have been removed in Tenant ${Utils.buildTenantName(tenant)})`
});
}
}

MODIFY
src/migration/tasks/UnmarkTransactionExtraInactivitiesTask.ts
src/migration/tasks/UnmarkTransactionExtraInactivitiesTask.ts
@@ -33,7 +33,7 @@ export default class UnmarkTransactionExtraInactivitiesTask extends MigrationTas
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrateTenant',
- message: `${result.modifiedCount} Transaction(s) have been marked to be recomputed in Tenant '${tenant.name}' ('${tenant.subdomain}')...`,
+ message: `${result.modifiedCount} Transaction(s) have been marked to be recomputed in Tenant ${Utils.buildTenantName(tenant)})...`,
});
}
}

MODIFY
src/migration/tasks/UpdateConsumptionsToObjectIDsTask.ts
src/migration/tasks/UpdateConsumptionsToObjectIDsTask.ts
@@ -75,7 +75,7 @@ export default class UpdateConsumptionsToObjectIDsTask extends MigrationTask {
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.MIGRATION,
module: MODULE_NAME, method: 'migrate',
- message: `Tenant ${tenant.name} (${tenant.id}): ${updated} consumptions have been updated`
+ message: `Tenant ${Utils.buildTenantName(tenant)} (${tenant.id}): ${updated} consumptions have been updated`
});
}
}

MODIFY
src/scheduler/tasks/CheckChargingStationTemplateTask.ts
src/scheduler/tasks/CheckChargingStationTemplateTask.ts
@@ -50,7 +50,7 @@ export default class CheckChargingStationTemplateTask extends SchedulerTask {
tenantID: tenant.id,
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'applyTemplateToChargingStations',
- message: `Bypassed tenant '${tenant.name}' ('${tenant.subdomain}')`
+ message: `Bypassed tenant ${Utils.buildTenantName(tenant)})`
});
return;
}
@@ -132,7 +132,7 @@ export default class CheckChargingStationTemplateTask extends SchedulerTask {
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
source: chargingStation.id,
module: MODULE_NAME, method: 'applyTemplateToChargingStations',
- message: `Apply Template's OCPP Parameters for '${chargingStation.id}' in Tenant '${tenant.name}' ('${tenant.subdomain}')`,
+ message: `Apply Template's OCPP Parameters for '${chargingStation.id}' in Tenant ${Utils.buildTenantName(tenant)})`,
});
// Request the latest configuration
const result = await Utils.executePromiseWithTimeout<OCPPChangeConfigurationCommandResult>(
@@ -144,7 +144,7 @@ export default class CheckChargingStationTemplateTask extends SchedulerTask {
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
source: chargingStation.id,
module: MODULE_NAME, method: 'applyTemplateToChargingStations',
- message: `Cannot request OCPP Parameters from '${chargingStation.id}' in Tenant '${tenant.name}' ('${tenant.subdomain}')`,
+ message: `Cannot request OCPP Parameters from '${chargingStation.id}' in Tenant ${Utils.buildTenantName(tenant)})`,
});
continue;
}
@@ -157,9 +157,9 @@ export default class CheckChargingStationTemplateTask extends SchedulerTask {
tenant.id,
ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
MODULE_NAME, 'applyTemplateToChargingStations', updatedOcppParameters,
- `{{inSuccess}} OCPP Parameter(s) were successfully synchronized, check details in the Tenant '${tenant.name}' ('${tenant.subdomain}')`,
- `{{inError}} OCPP Parameter(s) failed to be synchronized, check details in the Tenant '${tenant.name}' ('${tenant.subdomain}')`,
- `{{inSuccess}} OCPP Parameter(s) were successfully synchronized and {{inError}} failed to be synchronized, check details in the Tenant '${tenant.name}' ('${tenant.subdomain}')`,
+ `{{inSuccess}} OCPP Parameter(s) were successfully synchronized, check details in the Tenant ${Utils.buildTenantName(tenant)})`,
+ `{{inError}} OCPP Parameter(s) failed to be synchronized, check details in the Tenant ${Utils.buildTenantName(tenant)})`,
+ `{{inSuccess}} OCPP Parameter(s) were successfully synchronized and {{inError}} failed to be synchronized, check details in the Tenant ${Utils.buildTenantName(tenant)})`,
'All the OCPP Parameters are up to date'
);
}
@@ -170,7 +170,7 @@ export default class CheckChargingStationTemplateTask extends SchedulerTask {
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
source: chargingStation.id,
module: MODULE_NAME, method: 'applyTemplateToChargingStations',
- message: `Template update error in Tenant '${tenant.name}' ('${tenant.subdomain}'): ${error.message}`,
+ message: `Template update error in Tenant ${Utils.buildTenantName(tenant)}): ${error.message}`,
detailedMessages: { error: error.message, stack: error.stack }
});
}
@@ -180,7 +180,7 @@ export default class CheckChargingStationTemplateTask extends SchedulerTask {
tenantID: tenant.id,
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'applyTemplateToChargingStations',
- message: `${updated} Charging Stations have been processed with Template in Tenant '${tenant.name}' ('${tenant.subdomain}')`
+ message: `${updated} Charging Stations have been processed with Template in Tenant ${Utils.buildTenantName(tenant)})`
});
}
}

MODIFY
src/scheduler/tasks/SynchronizeTagsImportTask.ts
src/scheduler/tasks/SynchronizeTagsImportTask.ts
+import Tag, { ImportedTag } from '../../types/Tag';
+
import Constants from '../../utils/Constants';
+import { DataResult } from '../../types/DataResult';
import DbParams from '../../types/database/DbParams';
import { HTTPError } from '../../types/HTTPError';
import { LockEntity } from '../../types/Locking';
@@ -6,7 +9,6 @@ import LockingManager from '../../locking/LockingManager';
import Logging from '../../utils/Logging';
import SchedulerTask from '../SchedulerTask';
import { ServerAction } from '../../types/Server';
-import Tag from '../../types/Tag';
import TagStorage from '../../storage/mongodb/TagStorage';
import { TaskConfig } from '../../types/TaskConfig';
import Tenant from '../../types/Tenant';
@@ -19,16 +21,30 @@ export default class SynchronizeTagsImportTask extends SchedulerTask {
const synchronizeTagsImport = LockingManager.createExclusiveLock(tenant.id, LockEntity.TAGS, 'synchronize-tags-import');
if (await LockingManager.acquire(synchronizeTagsImport)) {
try {
- const dbParams: DbParams = { limit: Constants.EXPORT_PAGE_SIZE, skip: 0 };
- let importedTags = await TagStorage.getImportedTags(tenant.id, { withNoError: true }, dbParams);
- while (importedTags && !Utils.isEmptyArray(importedTags.result)) {
+ const dbParams: DbParams = { limit: Constants.IMPORT_PAGE_SIZE, skip: 0 };
+ let importedTags: DataResult<ImportedTag>;
+ do {
+ // Get the imported tags
+ importedTags = await TagStorage.getImportedTags(tenant.id, { withNoError: true }, dbParams);
for (const importedTag of importedTags.result) {
+ try {
+ // Existing tags
const foundTag = await TagStorage.getTag(tenant.id, importedTag.id);
if (foundTag) {
- importedTag.errorCode = HTTPError.TAG_ALREADY_EXIST_ERROR;
- importedTag.errorDescription = `Tag with ID '${foundTag.id}' already exists`;
- await TagStorage.saveImportedTag(tenant.id, importedTag);
- } else {
+ // Update it
+ await TagStorage.saveImportedTag(tenant.id, { ...foundTag, ...importedTag });
+ // Remove the imported Tag
+ await TagStorage.deleteImportedTag(tenant.id, importedTag.id);
+ // Log
+ await Logging.logDebug({
+ tenantID: tenant.id,
+ action: ServerAction.SYNCHRONIZE_TAGS,
+ module: MODULE_NAME, method: 'processTenant',
+ message: `Tag with id: ${importedTag.id} have been updated successfully in Tenant ${Utils.buildTenantName(tenant)}`
+ });
+ continue;
+ }
+ // New Tag
const tag: Tag = {
id: importedTag.id,
description: importedTag.description,
@@ -36,34 +52,36 @@ export default class SynchronizeTagsImportTask extends SchedulerTask {
deleted: false,
active: false,
createdBy: { id: importedTag.importedBy },
- createdOn: importedTag.importedOn
+ createdOn: importedTag.importedOn,
};
- try {
+ // Save the new Tag
await TagStorage.saveTag(tenant.id, tag);
+ // Remove the imported Tag
await TagStorage.deleteImportedTag(tenant.id, importedTag.id);
+ // Log
await Logging.logDebug({
tenantID: tenant.id,
action: ServerAction.SYNCHRONIZE_TAGS,
- module: MODULE_NAME, method: 'SYNCHRONIZE_TAGS',
- message: `Tag with id: ${importedTag.id} have been created in Tenant ${tenant.name}`
+ module: MODULE_NAME, method: 'processTenant',
+ message: `Tag with id: ${importedTag.id} have been created in Tenant ${Utils.buildTenantName(tenant)}`
});
} catch (error) {
+ // Update the imported Tag
importedTag.errorCode = HTTPError.GENERAL_ERROR;
importedTag.errorDescription = error.message;
+ // Update it
await TagStorage.saveImportedTag(tenant.id, importedTag);
- // Error
+ // Log
await Logging.logError({
tenantID: tenant.id,
action: ServerAction.SYNCHRONIZE_TAGS,
- module: MODULE_NAME, method: 'createTag',
- message: `An error occurred when importing tag with id: ${importedTag.id}`,
- detailedMessages: { error }
+ module: MODULE_NAME, method: 'processTenant',
+ message: `An error occurred while importing the Tag ID '${importedTag.id}'`,
+ detailedMessages: { error: error.message, stack: error.stack }
});
}
}
- }
- importedTags = await TagStorage.getImportedTags(tenant.id, { withNoError: true }, dbParams);
- }
+ } while (!Utils.isEmptyArray(importedTags?.result));
} catch (error) {
// Log error
await Logging.logActionExceptionMessage(tenant.id, ServerAction.SYNCHRONIZE_TAGS, error);

MODIFY
src/scheduler/tasks/SynchronizeUsersImportTask.ts
src/scheduler/tasks/SynchronizeUsersImportTask.ts
@@ -54,7 +54,7 @@ export default class SynchronizeUsersImportTask extends SchedulerTask {
tenantID: tenant.id,
action: ServerAction.SYNCHRONIZE_USERS,
module: MODULE_NAME, method: 'SYNCHRONIZE_USERS',
- message: `User with email: ${importedUser.email} have been created in Tenant ${tenant.name}`
+ message: `User with email: ${importedUser.email} have been created in Tenant ${Utils.buildTenantName(tenant)}`
});
} catch (error) {
importedUser.errorCode = HTTPError.GENERAL_ERROR;

MODIFY
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/EMSPTariffsEndpoint.ts
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/EMSPTariffsEndpoint.ts
@@ -76,7 +76,7 @@ export default class EMSPTariffsEndpoint extends AbstractEndpoint {
module: MODULE_NAME, method: 'getTariffRequest',
action: ServerAction.OCPI_GET_TARIFF,
errorCode: StatusCodes.BAD_REQUEST,
- message: `Simple Pricing setting not found on tenant ${tenant.name}`,
+ message: `Simple Pricing setting not found on Tenant ${Utils.buildTenantName(tenant)}`,
ocpiError: OCPIStatusCode.CODE_3000_GENERIC_SERVER_ERROR
});
}

MODIFY
src/utils/Constants.ts
src/utils/Constants.ts
@@ -31,6 +31,7 @@ export default class Constants {
public static readonly EXPORT_PDF_PAGE_SIZE = 100;
public static readonly EXPORT_PAGE_SIZE = 1000;
public static readonly EXPORT_RECORD_MAX_COUNT = 100000;
+ public static readonly IMPORT_PAGE_SIZE = 1000;
public static readonly DEFAULT_TENANT = 'default';
public static readonly DEFAULT_TENANT_OBJECT = Object.freeze({

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -1325,6 +1325,10 @@ export default class Utils {
}
}
+ public static buildTenantName(tenant: Tenant): string {
+ return `'${tenant.name}' ('${tenant.subdomain}'`;
+ }
+
public static isChargingStationIDValid(name: string): boolean {
// eslint-disable-next-line no-useless-escape
return /^[A-Za-z0-9_\.\-~]*$/.test(name);

Refactored SynchronizeTagsImportTask coding