Fix coverage: add /api/coverage route, remove stray gather code from loadCoverage
This commit is contained in:
45
scripts/migrate_all.py
Normal file
45
scripts/migrate_all.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import json, psycopg2, os
|
||||
from pathlib import Path
|
||||
from migrate_to_db import migrate_file
|
||||
|
||||
INDEX_PATH = "/mnt/kingston/seismic_webapp/data/index.json"
|
||||
DB_URL = "postgresql://postgres:seismic_pass@db:5432/seismic_data"
|
||||
|
||||
def update_status(processed, total, current):
|
||||
try:
|
||||
conn = psycopg2.connect(DB_URL)
|
||||
cur = conn.cursor()
|
||||
cur.execute("UPDATE migration_status SET processed_files = %s, total_files = %s, current_file = %s, last_update = NOW() WHERE id = 1", (processed, total, current))
|
||||
conn.commit()
|
||||
cur.close()
|
||||
conn.close()
|
||||
except Exception as e:
|
||||
print(f"Status update error: {e}")
|
||||
|
||||
def main():
|
||||
with open(INDEX_PATH, 'r') as f:
|
||||
index = json.load(f)
|
||||
|
||||
nodes = index.get('nodes', {})
|
||||
all_files = []
|
||||
for nid, node in nodes.items():
|
||||
for f in node.get('files', []):
|
||||
if '_data_' in f['path']:
|
||||
all_files.append((nid, f))
|
||||
|
||||
total = len(all_files)
|
||||
print(f"Starting migration for {total} files...")
|
||||
|
||||
for i, (nid, f) in enumerate(all_files):
|
||||
filename = os.path.basename(f['path'])
|
||||
update_status(i, total, filename)
|
||||
try:
|
||||
# Migration de 1h de chaque fichier
|
||||
migrate_file(f['path'], nid, f.get('channel', 'ch0'), duration_sec=3600)
|
||||
except Exception as e:
|
||||
print(f"Error migrating {filename}: {e}")
|
||||
|
||||
update_status(total, total, "Terminé")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user