Can now set up automated maintenance.

pull/586/head
jprochazka 2024-07-13 01:24:38 -04:00
rodzic ece83487ee
commit 1892ac1462
7 zmienionych plików z 38 dodań i 26 usunięć

Wyświetl plik

@ -6,6 +6,7 @@ The following is a history of the changes made to this project.
### Portal
* Can now toggle daily data purges as well specify the amount of days to keep within the portal.
* Rewrote the aircraft.py script and fixed issues found with newer versions of dump1090.
* Rewrote the maintenance.py script and addressed issue mentioned in an incompatible pull request.
* The flights page now only shows links when position information is present in the database.

Wyświetl plik

@ -7,9 +7,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/admin/assets/css/bootstrap.min.css">
<link rel="stylesheet" href="/admin/assets/css/bootstrap-theme.min.css">
<?php if (basename($_SERVER['PHP_SELF']) == "index.php") { ?>
<link rel="stylesheet" href="/admin/assets/css/jquery.datetimepicker.css">
<?php } ?>
<link rel="stylesheet" href="/admin/assets/css/admin.css">
<script src="/admin/assets/js/jquery-3.1.1.min.js"></script>
<script src="/admin/assets/js/bootstrap.min.js"></script>

Wyświetl plik

@ -7,7 +7,7 @@
// //
// The MIT License (MIT) //
// //
// Copyright (c) 2015-2016 Joseph A. Prochazka //
// Copyright (c) 2015 Joseph A. Prochazka //
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy //
// of this software and associated documentation files (the "Software"), to deal //
@ -154,6 +154,10 @@
if (isset($_POST['hideNavbarAndFooter']) && $_POST['hideNavbarAndFooter'] == "TRUE")
$hideNavbarAndFooter = TRUE;
$purgeOlderData = FALSE;
if (isset($_POST['purgeOlderData']) && $_POST['purgeOlderData'] == "TRUE")
$purgeOlderData = TRUE;
// Update settings using those supplied by the form.
$common->updateSetting("siteName", $_POST['siteName']);
$common->updateSetting("template", $_POST['template']);
@ -183,6 +187,8 @@
$common->updateSetting("enableWebNotifications", $enableWebNotifications);
$common->updateSetting("googleMapsApiKey", $_POST['googleMapsApiKey']);
$common->updateSetting("hideNavbarAndFooter", $hideNavbarAndFooter);
$common->updateSetting("purge_older_data", $purgeOlderData);
$common->updateSetting("days_to_save", $_POST['daysToSave']);
// Purge older flight positions.
if (isset($_POST['purgepositions'])) {
@ -223,7 +229,7 @@
}
$enableWebNotifications = $common->getSetting("enableWebNotifications");
// Get general settings from settings.xml.
// Get general settings.
$siteName = $common->getSetting("siteName");
$currentTemplate = $common->getSetting("template");
$defaultPage = $common->getSetting("defaultPage");
@ -231,7 +237,7 @@
$timeZone = $common->getSetting("timeZone");
$googleMapsApiKey = $common->getSetting("googleMapsApiKey");
// Get navigation settings from settings.xml.
// Get navigation settings.
$enableFlights = $common->getSetting("enableFlights");
$enableBlog = $common->getSetting("enableBlog");
$enableInfo = $common->getSetting("enableInfo");
@ -242,7 +248,7 @@
$enablePfclient = $common->getSetting("enablePfclient");
$hideNavbarAndFooter = $common->getSetting("hideNavbarAndFooter");
// Get aggregate site settings from settings.xml.
// Get aggregate site settings.
$enableFlightAwareLink = $common->getSetting("enableFlightAwareLink");
$flightAwareLogin = $common->getSetting("flightAwareLogin");
$flightAwareSite = $common->getSetting("flightAwareSite");
@ -252,14 +258,18 @@
$flightRadar24Id = $common->getSetting("flightRadar24Id");
$enableAdsbExchangeLink = $common->getSetting("enableAdsbExchangeLink");
// Get units of measurement setting from settings.xml.
// Get units of measurement settings.
$measurementRange = $common->getSetting("measurementRange");
$measurementTemperature = $common->getSetting("measurementTemperature");
$measurementBandwidth = $common->getSetting("measurementBandwidth");
// Get the network interface from settings.xml.
// Get the network interface settings.
$networkInterface = $common->getSetting("networkInterface");
// Get data purge settings.
$purgeOlderData = $common->getSetting("purge_older_data");
$daysToSave = $common->getSetting("days_to_save");
// Create an array of all directories in the template folder.
$templates = array();
$path = "../templates/";
@ -578,20 +588,15 @@
<div class="panel-heading">Purge Positions</div>
<div class="panel-body">
<p>Current Database Size: <?php echo $common->getDatabaseSize("mb"); ?>MB</p>
<div class="form-group">
<label for="purgepositionspicker">Purge flight positions old than...</label><br />
<input type="text" class="form-control" id="purgepositionspicker" name="purgepositionspicker" autocomplete="off" <?php ($settings::db_driver == "xml" ? print ' disabled' : ''); ?>>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="purgepositions" value="purge"<?php ($settings::db_driver == "xml" ? print ' disabled' : ''); ?>> Check to confirm purge of data.
<input type="checkbox" id="purgeOlderData" name="purgeOlderData" value="TRUE"<?php ($purgeOlderData == 1 ? print ' checked' : ''); ?><?php ($settings::db_driver == "xml" ? print ' disabled' : ''); ?>> Enable daily purges of older flight data.
</label>
</div>
<script type="text/javascript">
jQuery('#purgepositionspicker').datetimepicker({
inline:true
});
</script>
<div class="form-group">
<label for="daystosave"">Keep only data newer than X days.</label>
<input type="text" class="form-control" id="daysToSave" name="daysToSave" value="<?php echo $daysToSave; ?>"<?php ($settings::db_driver == "xml" ? print ' disabled' : ''); ?>>
</div>
</div>
</div>
</div>

Wyświetl plik

@ -7,7 +7,7 @@
// //
// The MIT License (MIT) //
// //
// Copyright (c) 2015-2024 Joseph A. Prochazka //
// Copyright (c) 2015 Joseph A. Prochazka //
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy //
// of this software and associated documentation files (the "Software"), to deal //
@ -443,7 +443,8 @@ EOF;
$common->addSetting('enableWebNotifications', FALSE);
$common->addSetting('googleMapsApiKey', '');
$common->addSetting("hideNavbarAndFooter", FALSE);
$common->addSetting("purgeAircraft", FALSE);
$common->addSetting("purge_older_data", FALSE);
$common->addSetting("days_to_save", "30");
$common->addSetting("advancedMapCenterLatitude", "41.3683798");
$common->addSetting("advancedMapCenterLongitude", "-82.1076486");

Wyświetl plik

@ -59,6 +59,14 @@
$sth->execute();
$sth = NULL;
// Rename purgeAircraft to purge_older_data.
$purge_older_data = $common->getSetting('purgeAircraft');
$common->deleteSetting('purgeAircraft');
$common->addSetting("purge_older_data", $purge_older_data);
// Add days to save setting.
$common->addSetting("days_to_save", "30");
// The upgrade process completed successfully.
$results['success'] = TRUE;
$results['message'] = "Upgrade to v2.8.4 successful.";

Wyświetl plik

@ -7,7 +7,7 @@
// //
// The MIT License (MIT) //
// //
// Copyright (c) 2015-2024 Joseph A. Prochazka //
// Copyright (c) 2015 Joseph A. Prochazka //
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy //
// of this software and associated documentation files (the "Software"), to deal //

Wyświetl plik

@ -37,20 +37,20 @@ class MaintenanceProcessor(object):
self.log("Getting maintenance settings from the database")
purge_old_aircraft = False
try:
cursor.execute("SELECT value FROM adsb_settings WHERE name = 'purgeAircraft'")
cursor.execute("SELECT value FROM adsb_settings WHERE name = 'purge_older_data'")
result = cursor.fetchone()[0]
purge_old_aircraft = result.lower() in ['true', '1']
except Exception as ex:
logging.error(f"Error encountered while getting value for setting purgeAircraft", exc_info=ex)
logging.error(f"Error encountered while getting value for setting purge_older_data", exc_info=ex)
return
if purge_old_aircraft:
cutoff_date = datetime.now() - timedelta(years = 20)
try:
cursor.execute("SELECT value FROM adsb_settings WHERE name = 'purgeDaysOld'")
cursor.execute("SELECT value FROM adsb_settings WHERE name = 'days_to_save'")
days_to_save = cursor.fetchone()[0]
except Exception as ex:
logging.error(f"Error encountered while getting value for setting purgeDaysOld", exc_info=ex)
logging.error(f"Error encountered while getting value for setting days_to_save", exc_info=ex)
return
cutoff_date = datetime.now() - timedelta(days = days_to_save)