Skip to content

Commit

Permalink
Merge pull request #22 from BouyguesTelecom/improve/dx-docker-compose
Browse files Browse the repository at this point in the history
add clean catalog on server.ts
  • Loading branch information
AmelieLoulergue authored Dec 1, 2024
2 parents 9a4d3f6 + c528327 commit 022a401
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { redisHandler } from './catalog/redis/connection';
import { getLastDump } from './delegated-storage/index';
import { minioClient } from './delegated-storage/s3/connection';
import fetch from 'node-fetch';
import { deleteCatalogItem, getCatalog } from './catalog';

const port = parseInt(process.env.PORT, 10) || 3001;
const standalone = process.env.DELEGATED_STORAGE_METHOD === 'STANDALONE';
Expand Down Expand Up @@ -34,6 +35,14 @@ const connectToRedisWithRetry = async (maxRetries, delay) => {
while (attempts < maxRetries) {
try {
await redisHandler.connectClient();
const {data:catalog} = await getCatalog()
if(catalog.length){
for (const item of catalog){
if(item.unique_name.includes('/tests/')){
await deleteCatalogItem(item.unique_name)
}
}
}
return;
} catch (err) {
attempts++;
Expand Down

0 comments on commit 022a401

Please sign in to comment.