-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch-routes.js
More file actions
19 lines (16 loc) · 935 Bytes
/
Copy pathpatch-routes.js
File metadata and controls
19 lines (16 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const fs = require('fs');
let code = fs.readFileSync('backend/api/routes.py', 'utf8');
code = code.replace(
'await arq_pool.enqueue_job("process_file_task", job.id)',
'if arq_pool:\n try:\n await arq_pool.enqueue_job("process_file_task", job.id)\n except Exception:\n pass'
);
code = code.replace(
'cached_graph = await arq_pool.get(cache_key)',
'cached_graph = None\n if arq_pool:\n try:\n cached_graph = await arq_pool.get(cache_key)\n except Exception:\n pass'
);
code = code.replace(
'await arq_pool.setex(cache_key, 3600, json.dumps(repo.architecture_graph))',
'if arq_pool:\n try:\n await arq_pool.setex(cache_key, 3600, json.dumps(repo.architecture_graph))\n except Exception:\n pass'
);
fs.writeFileSync('backend/api/routes.py', code);
console.log('Patched routes for missing Redis');