MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / get_interrupted_scans

Method get_interrupted_scans

db_manager.py:2056–2087  ·  view source on GitHub ↗

Get scans that were interrupted (status is 'running' or 'pending' with old updated_at). These are scans that need recovery after restart. Returns: List of interrupted scan jobs

(self)

Source from the content-addressed store, hash-verified

2054 if result.get('options'):
2055 try:
2056 result['options'] = json.loads(result['options'])
2057 except json.JSONDecodeError:
2058 result['options'] = {}
2059 results.append(result)
2060
2061 return results
2062 except Exception as e:
2063 logger.error(f"Failed to get scan jobs: {e}")
2064 return []
2065
2066 def get_interrupted_scans(self) -> List[Dict[str, Any]]:
2067 """
2068 Get scans that were interrupted (status is 'running' or 'pending' with old updated_at).
2069 These are scans that need recovery after restart.
2070
2071 Returns:
2072 List of interrupted scan jobs
2073 """
2074 try:
2075 with self.get_connection() as conn:
2076 cursor = conn.cursor()
2077 # Scans marked as 'running' are potentially interrupted
2078 cursor.execute("""
2079 SELECT * FROM scan_jobs
2080 WHERE status IN ('running', 'pending')
2081 ORDER BY created_at DESC
2082 """)
2083
2084 results = []
2085 for row in cursor.fetchall():
2086 result = dict(row)
2087 if result.get('options'):
2088 try:
2089 result['options'] = json.loads(result['options'])
2090 except json.JSONDecodeError:

Callers 1

Calls 7

get_connectionMethod · 0.95
cursorMethod · 0.80
appendMethod · 0.80
errorMethod · 0.80
executeMethod · 0.45
fetchallMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected