Expose an api to save the application state which stores the data from query tool, ERD, schema-diff, psql
()
| 287 | ) |
| 288 | @pga_login_required |
| 289 | def save_application_state(): |
| 290 | """ |
| 291 | Expose an api to save the application state which stores the data from |
| 292 | query tool, ERD, schema-diff, psql |
| 293 | """ |
| 294 | data = json.loads(request.data) |
| 295 | trans_id = data['trans_id'] |
| 296 | fernet = Fernet(current_app.config['SECRET_KEY'].encode()) |
| 297 | tool_data = fernet.encrypt(json.dumps(data['tool_data']).encode()) |
| 298 | connection_info = data['connection_info'] \ |
| 299 | if 'connection_info' in data else None |
| 300 | if (connection_info and 'open_file_name' in connection_info and |
| 301 | connection_info['open_file_name']): |
| 302 | file_path = get_complete_file_path(connection_info['open_file_name']) |
| 303 | connection_info['last_saved_file_hash'] = ( |
| 304 | get_last_saved_file_hash(file_path, trans_id)) |
| 305 | |
| 306 | try: |
| 307 | data_entry = ApplicationState( |
| 308 | uid=current_user.id, id=trans_id,connection_info=connection_info, |
| 309 | tool_data=tool_data) |
| 310 | |
| 311 | db.session.merge(data_entry) |
| 312 | db.session.commit() |
| 313 | except Exception as e: |
| 314 | print(e) |
| 315 | db.session.rollback() |
| 316 | |
| 317 | return make_json_response( |
| 318 | data={ |
| 319 | 'status': True, |
| 320 | 'msg': 'Success', |
| 321 | }) |
| 322 | |
| 323 | |
| 324 | def get_last_saved_file_hash(file_path, trans_id): |
nothing calls this directly
no test coverage detected