We don't want to hard delete a sequence because it can cause foreign key issues. ie the instance sticks around or relates to the id, it then attempts to save it, but the sequence doesnt' exist also if we want todo recovery things in the future this could have issues too...
(session, file, label_file_id, sequence_id)
| 149 | |
| 150 | |
| 151 | def delete_sequence_shared(session, file, label_file_id, sequence_id): |
| 152 | """ |
| 153 | We don't want to hard delete a sequence because it can cause |
| 154 | foreign key issues. ie the instance sticks around or relates to the id, |
| 155 | it then attempts to save it, but the sequence doesnt' exist |
| 156 | also if we want todo recovery things in the future this could have issues too... |
| 157 | |
| 158 | """ |
| 159 | |
| 160 | if label_file_id is None or sequence_id is None: |
| 161 | return "a required argument is none", 400, {'ContentType': 'application/json'} |
| 162 | |
| 163 | # There are multiple sequences per video and per label, so need ID too |
| 164 | # Could of course just do by ID but feels like an extra "check" that other stuff matches too |
| 165 | |
| 166 | sequence = session.query(Sequence).filter( |
| 167 | Sequence.video_file_id == file.id, |
| 168 | Sequence.label_file_id == label_file_id, |
| 169 | Sequence.id == sequence_id).first() |
| 170 | |
| 171 | if sequence is None: |
| 172 | return jsonify("Not found"), 400 |
| 173 | |
| 174 | for instance in sequence.instance_list: |
| 175 | instance.do_soft_delete() |
| 176 | session.add(instance) |
| 177 | |
| 178 | sequence.archived = True |
| 179 | session.add(sequence) |
| 180 | |
| 181 | return jsonify(success = True), 200 |
| 182 | |
| 183 | |
| 184 | #### UPDATE |
no test coverage detected