Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
benzekrimaha committed Jan 22, 2025
1 parent 916ce31 commit b84f065
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"lint": "eslint $(git ls-files '*.js')",
"test:unit": "LOCATION_CONFIG_FILE='tests/conf/locationConfig.json' yarn jest --verbose --logHeapUsage --projects jest.config.js --coverage --testPathPattern='tests/unit/[\\w/-]+\\.[tj]s'",
"test:functional": "LOCATION_CONFIG_FILE='tests/conf/locationConfig.json' yarn jest --verbose --logHeapUsage --projects jest.config.js --coverage --testPathPattern='tests/functional/[\\w/-]+\\.[tj]s'"
"test:functional": "LOCATION_CONFIG_FILE='tests/conf/locationConfig.json' yarn jest --verbose --logHeapUsage --projects jest.config.js --coverage --testPathPattern='tests/functional/collectBucketMetricsAndUpdateBucketCapacityInfo.js'"
},
"repository": {
"type": "git",
Expand Down
30 changes: 18 additions & 12 deletions utils/S3UtilsMongoClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ class S3UtilsMongoClient extends MongoClientInterface {
'value.creationDate': 1,
},
});
const TEST = await this.getCollection(USERSBUCKET).find({});
console.log('TEST', TEST);
const TEST = await this.getCollection(USERSBUCKET).countDocuments({});
const TEST2 = await this.getCollection(METASTORE).countDocuments({});
const TEST3 = await this.getCollection(INFOSTORE).countDocuments({});
console.log('TEST', { TEST, TEST2, TEST3 });
const usersBucketCreationDatesArray = await cursorUsersBucketCreationDates.toArray();
console.log('USERS BUCKET CREATION DATES ARRAY', usersBucketCreationDatesArray);
return usersBucketCreationDatesArray
Expand All @@ -85,6 +87,7 @@ class S3UtilsMongoClient extends MongoClientInterface {

async updateInflightDeltas(allMetrics, log) {
let cursor;
console.log('WE ARE HEEEEEEEEERE');
try {
if (!allMetrics || !Array.isArray(allMetrics) || allMetrics.length === 0) {
return allMetrics;
Expand All @@ -95,7 +98,8 @@ class S3UtilsMongoClient extends MongoClientInterface {
'usedCapacity._inflight': 1,
},
});


Check failure on line 101 in utils/S3UtilsMongoClient.js

View workflow job for this annotation

GitHub Actions / tests

Trailing spaces not allowed
console.log('CURSOR', cursor);
const inflights = await cursor.toArray();
// convert inflights to a map with _id: usedCapacity._inflight
const inflightsMap = inflights.reduce((map, obj) => {
Expand Down Expand Up @@ -822,20 +826,20 @@ class S3UtilsMongoClient extends MongoClientInterface {
}

static convertNumberToLong(obj) {
console.log('ON EST ICIIII SA RACE');
if (typeof obj !== 'object' || obj === null) {
return obj;
console.log('THIS IS THE OBJ', obj);

Check failure on line 830 in utils/S3UtilsMongoClient.js

View workflow job for this annotation

GitHub Actions / tests

Expected indentation of 12 spaces but found 10
return obj;

Check failure on line 831 in utils/S3UtilsMongoClient.js

View workflow job for this annotation

GitHub Actions / tests

Expected indentation of 12 spaces but found 10
}

Check failure on line 833 in utils/S3UtilsMongoClient.js

View workflow job for this annotation

GitHub Actions / tests

Trailing spaces not allowed
const newObj = {};
for (const key in obj) {
if (typeof obj[key] === 'number') {
// convert number to Long
newObj[key] = Long.fromNumber(obj[key]);
} else {
// recursively convert nested object properties to Long
newObj[key] = S3UtilsMongoClient.convertNumberToLong(obj[key]);
}
if (typeof obj[key] === 'bigint') {

Check failure on line 836 in utils/S3UtilsMongoClient.js

View workflow job for this annotation

GitHub Actions / tests

Expected indentation of 12 spaces but found 10
newObj[key] = Long.fromString(obj[key].toString());

Check failure on line 837 in utils/S3UtilsMongoClient.js

View workflow job for this annotation

GitHub Actions / tests

Expected indentation of 16 spaces but found 12
} else {

Check failure on line 838 in utils/S3UtilsMongoClient.js

View workflow job for this annotation

GitHub Actions / tests

Expected indentation of 12 spaces but found 10
newObj[key] = S3UtilsMongoClient.convertNumberToLong(obj[key]);

Check failure on line 839 in utils/S3UtilsMongoClient.js

View workflow job for this annotation

GitHub Actions / tests

Expected indentation of 16 spaces but found 12
}

Check failure on line 840 in utils/S3UtilsMongoClient.js

View workflow job for this annotation

GitHub Actions / tests

Expected indentation of 12 spaces but found 10
}
console.log('NEW OBJ', newObj);
return newObj;
}

Expand All @@ -856,13 +860,15 @@ class S3UtilsMongoClient extends MongoClientInterface {
log.info('updateStorageConsumptionMetrics: updating storage metrics');

// update the inflights
console.log('updatedStorageMetricsList', updatedStorageMetricsList);
updatedStorageMetricsList = await this.updateInflightDeltas(updatedStorageMetricsList, log);

// Drop the temporary collection if it exists
try {
await this.getCollection(INFOSTORE_TMP).drop();
} catch (err) {
if (err.codeName !== 'NamespaceNotFound') {
console.log('we are actually heeeere');
throw err;
}
}
Expand Down

0 comments on commit b84f065

Please sign in to comment.