Do not retrieve all transactions -> use DB_PARAMS_COUNT_ONLY, Fixed code formatting.
MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -3,7 +3,6 @@ import { ActionsResponse, ImportStatus } from '../../../../types/GlobalType';
import { AsyncTaskType, AsyncTasks } from '../../../../types/AsyncTask';
import { HTTPAuthError, HTTPError } from '../../../../types/HTTPError';
import { NextFunction, Request, Response } from 'express';
-import { OCPITokenType, OCPITokenWhitelist } from '../../../../types/ocpi/OCPIToken';
import Tag, { ImportedTag, TagRequiredImportProperties } from '../../../../types/Tag';
import AppAuthError from '../../../../exception/AppAuthError';
@@ -21,6 +20,7 @@ import LockingManager from '../../../../locking/LockingManager';
import Logging from '../../../../utils/Logging';
import OCPIClientFactory from '../../../../client/ocpi/OCPIClientFactory';
import { OCPIRole } from '../../../../types/ocpi/OCPIRole';
+import { OCPITokenWhitelist } from '../../../../types/ocpi/OCPIToken';
import OCPIUtils from '../../../ocpi/OCPIUtils';
import { ServerAction } from '../../../../types/Server';
import { StatusCodes } from 'http-status-codes';
@@ -249,8 +249,9 @@ export default class TagService {
action: action
});
}
- const nbrTransactions = await TransactionStorage.getTransactions(req.user.tenantID,{ tagIDs:[filteredRequest.id.toUpperCase()] }, Constants.DB_PARAMS_MAX_LIMIT);
- if (nbrTransactions.count > 0) {
+ const transactions = await TransactionStorage.getTransactions(req.user.tenantID,
+ { tagIDs:[filteredRequest.id.toUpperCase()] }, Constants.DB_PARAMS_COUNT_ONLY);
+ if (transactions.count > 0) {
throw new AppError({
source: Constants.CENTRAL_SERVER,
errorCode: HTTPError.TAG_ALREADY_EXIST_ERROR,

MODIFY
src/storage/mongodb/UserStorage.ts
src/storage/mongodb/UserStorage.ts
@@ -920,16 +920,16 @@ export default class UserStorage {
const uniqueTimerID = Logging.traceStart(tenantID, MODULE_NAME, 'deleteUser');
// Check Tenant
await DatabaseUtils.checkTenant(tenantID);
+ // Delete User Image
+ await global.database.getCollection<any>(tenantID, 'userimages')
+ .findOneAndDelete({ '_id': Utils.convertToObjectID(id) });
// Delete Site Users
await global.database.getCollection<any>(tenantID, 'siteusers')
.deleteMany({ 'userID': Utils.convertToObjectID(id) });
- // Delete Image
- await global.database.getCollection<any>(tenantID, 'userimages')
- .findOneAndDelete({ '_id': Utils.convertToObjectID(id) });
// Delete Tags
await global.database.getCollection<any>(tenantID, 'tags')
.deleteMany({ 'userID': Utils.convertToObjectID(id) });
- // Delete connections
+ // Delete Connections
await global.database.getCollection<any>(tenantID, 'connections')
.deleteMany({ 'userId': Utils.convertToObjectID(id) });
// Delete User

Do not retrieve all transactions -> use DB_PARAMS_COUNT_ONLY, Fixed code formatting.