Skip to content

Commit

Permalink
add system function to delete daytime data
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronwmorris committed Aug 21, 2023
1 parent 6dfa758 commit d57fc83
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 0 deletions.
37 changes: 37 additions & 0 deletions indi_allsky/flask/templates/system.html
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,23 @@

<hr />

<div class="row">
<div class="col-sm-2"></div>
<div class="col-sm-2">Flush Daytime Images and Timelapses</div>
<div class="col-sm-2">
<input class="form-check-input" id="FLUSH_DAYTIME_CONFIRM1" name="FLUSH_DAYTIME_CONFIRM1" type="checkbox" value="y"> Confirm 1
</div>
<div class="col-sm-2">
<button class="btn btn-danger" id="button_flush_daytime">Flush Daytime</button>
</div>
<div class="col-sm-2">
<input class="form-check-input" id="FLUSH_DAYTIME_CONFIRM2" name="FLUSH_DAYTIME_CONFIRM2" type="checkbox" value="y"> Confirm 2
</div>
</div>

<hr />


</div><!-- end tab -->
</div>

Expand Down Expand Up @@ -894,6 +911,26 @@
button_click('system', 'flush_timelapses');
});

$("#button_flush_daytime").on("click", function() {
if (! $("#FLUSH_DAYTIME_CONFIRM1").prop('checked')) {
console.log('Flush checkbox not checked');
return;
}

if (! $("#FLUSH_DAYTIME_CONFIRM2").prop('checked')) {
console.log('Flush checkbox not checked');
return;
}

$("#loader_shutdown").css({'display' : 'block'});
$("#button_flush_daytime").prop('disabled', true);

$("#FLUSH_DAYTIME_CONFIRM1").prop('checked', false);
$("#FLUSH_DAYTIME_CONFIRM2").prop('checked', false);

button_click('system', 'flush_daytime');
});



function reloadPage() {
Expand Down
101 changes: 101 additions & 0 deletions indi_allsky/flask/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2386,6 +2386,21 @@ def dispatch_request(self):
'success-message' : '{0:d} Files Deleted'.format(file_count),
}
return jsonify(json_data)
elif command == 'flush_daytime':
if not self.verify_admin_network():
json_data = {
'form_global' : ['Request not from admin network (flask.json)'],
}
return jsonify(json_data), 400


file_count = self.flushDaytime(session['camera_id'])

json_data = {
'success-message' : '{0:d} Files Deleted'.format(file_count),
}
return jsonify(json_data)

else:
errors_data = {
'COMMAND_HIDDEN' : ['Unhandled command'],
Expand Down Expand Up @@ -2584,6 +2599,92 @@ def flushTimelapses(self, camera_id):
return file_count


def flushDaytime(self, camera_id):
file_count = 0

### Images
image_query = IndiAllSkyDbImageTable.query\
.join(IndiAllSkyDbImageTable.camera)\
.filter(IndiAllSkyDbCameraTable.id == camera_id)\
.filter(IndiAllSkyDbImageTable.night == sa_false())

file_count += image_query.count()

for i in image_query:
i.deleteAsset()
db.session.delete(i)

db.session.commit()


### FITS Images
fits_image_query = IndiAllSkyDbFitsImageTable.query\
.join(IndiAllSkyDbFitsImageTable.camera)\
.filter(IndiAllSkyDbCameraTable.id == camera_id)\
.filter(IndiAllSkyDbFitsImageTable.night == sa_false())

file_count += fits_image_query.count()

for i in fits_image_query:
i.deleteAsset()
db.session.delete(i)

db.session.commit()


### RAW Images
raw_image_query = IndiAllSkyDbRawImageTable.query\
.join(IndiAllSkyDbRawImageTable.camera)\
.filter(IndiAllSkyDbCameraTable.id == camera_id)\
.filter(IndiAllSkyDbRawImageTable.night == sa_false())

file_count += raw_image_query.count()

for i in raw_image_query:
i.deleteAsset()
db.session.delete(i)

db.session.commit()


### Timelapses
video_query = IndiAllSkyDbVideoTable.query\
.join(IndiAllSkyDbVideoTable.camera)\
.filter(IndiAllSkyDbCameraTable.id == camera_id)\
.filter(IndiAllSkyDbVideoTable.night == sa_false())


file_count += video_query.count()

for v in video_query:
v.deleteAsset()
db.session.delete(v)

db.session.commit()


### Keograms
keogram_query = IndiAllSkyDbKeogramTable.query\
.join(IndiAllSkyDbKeogramTable.camera)\
.filter(IndiAllSkyDbCameraTable.id == camera_id)\
.filter(IndiAllSkyDbKeogramTable.night == sa_false())

file_count += keogram_query.count()


for k in keogram_query:
k.deleteAsset()
db.session.delete(k)

db.session.commit()

## no startrails
## no startrail videos


return file_count


def validateDbEntries(self):
message_list = list()

Expand Down

0 comments on commit d57fc83

Please sign in to comment.