def append_query_executions_to_data_cell( data_cell_id, query_execution_ids=[], commit=True, session=None ): session.query(DataCellQueryExecution).filter( DataCellQueryExecution.data_cell_id == data_cell_id ).update({DataCellQueryExecution.latest: False}) for index, qid in enumerate(query_execution_ids): dcqe = DataCellQueryExecution( data_cell_id=data_cell_id, query_execution_id=qid, latest=(index == len(query_execution_ids)), ) session.add(dcqe) if commit: session.commit()
def copy_cell_history(from_cell_id, to_cell_id, commit=True, session=None): # Remove all old execution for to_cell_id just for precaution session.query(DataCellQueryExecution).filter_by( data_cell_id=to_cell_id).delete() all_executions = (session.query(DataCellQueryExecution).filter_by( data_cell_id=from_cell_id).all()) session.bulk_save_objects([ DataCellQueryExecution( query_execution_id=execution.query_execution_id, data_cell_id=to_cell_id, latest=execution.latest, ) for idx, execution in enumerate(all_executions) ]) if commit: session.commit()
def append_query_executions_to_data_cell(data_cell_id, query_execution_ids=[], commit=True, session=None): session.query(DataCellQueryExecution).filter( DataCellQueryExecution.data_cell_id == data_cell_id).update( {DataCellQueryExecution.latest: False}) for qid in query_execution_ids: latest_query_execution = get_last_query_execution_from_cell( data_cell_id, session=session) dcqe = DataCellQueryExecution( data_cell_id=data_cell_id, query_execution_id=qid, latest=(not latest_query_execution or qid > latest_query_execution.id), ) session.add(dcqe) if commit: session.commit()