forked from econpy/torque
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a major, structural change which represents a new release. Th…
…e entire structure of the data storage has been changed. Instead of a single raw_logs table, it's now broken into months. Additionally, session information has been broken out of the raw_logs and is solely stored in the sessions table. In order to accomplish this, there is a MAJOR database restructuring, requiring the execution of 'db_upgrade.php' which can take HOURS to run depending on how much data you have. PLEASE BACK UP YOUR DATABASE BEFORE RUNNING THAT. PLEASE LOOK AT THE ACTUAL CODE I AM RUNNING and consider running it manually. The most important user-facing changes...1) session filtering is now Year_Month instead of year AND month. 2) The GPS coordinates have been changed from float to Double, making the lines smoother. 3) You can now select favorite PIDs in the PID Edit page, and those are now auto-selected to be populated for plotting when the app loads.
- Loading branch information
1 parent
5a7d7d6
commit e555902
Showing
17 changed files
with
477 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
require_once ('db.php'); | ||
require_once ('auth_app.php'); | ||
|
||
mysqli_query($con, "ALTER TABLE $db_keys_table ADD COLUMN favorite TINYINT(1) NOT NULL DEFAULT 0") or die(mysqli_error($con)); | ||
// Update existing tables to handle new data structures | ||
$table_list = mysqli_query($con, "SELECT table_name FROM INFORMATION_SCHEMA.tables WHERE table_schema = '$db_name' and table_name like '$db_table%' ORDER BY table_name DESC;"); | ||
while( $row = mysqli_fetch_assoc($table_list) ) { | ||
$db_table_name = $row["table_name"]; | ||
// Change the GPS Latitude and Longitude datapoints from Float to Double to improve accuracy | ||
$sqlLatQuery = "ALTER TABLE $db_table_name MODIFY kff1006 DOUBLE NOT NULL DEFAULT '0'"; | ||
mysqli_query($con, $sqlLatQuery) or die(mysqli_error($con)); | ||
$sqlLongQuery = "ALTER TABLE $db_table_name MODIFY kff1005 DOUBLE NOT NULL DEFAULT '0'"; | ||
mysqli_query($con, $sqlLongQuery) or die(mysqli_error($con)); | ||
// Delete columns which are now redundant and just stored with the session | ||
$sqlVQuery = "ALTER TABLE $db_table_name DROP COLUMN v"; | ||
mysqli_query($con, $sqlVQuery) or die(mysqli_error($con)); | ||
$sqlIdQuery = "ALTER TABLE $db_table_name DROP COLUMN id"; | ||
mysqli_query($con, $sqlIdQuery) or die(mysqli_error($con)); | ||
$sqlEmlQuery = "ALTER TABLE $db_table_name DROP COLUMN eml"; | ||
mysqli_query($con, $sqlEmlQuery) or die(mysqli_error($con)); | ||
$sqlProfileNameQuery = "ALTER TABLE $db_table_name DROP COLUMN profileName"; | ||
mysqli_query($con, $sqlProfileNameQuery) or die(mysqli_error($con)); | ||
$sqlProfileFuelTypeQuery = "ALTER TABLE $db_table_name DROP COLUMN profileFuelType"; | ||
mysqli_query($con, $sqlProfileFuelTypeQuery) or die(mysqli_error($con)); | ||
$sqlProfileWeightQuery = "ALTER TABLE $db_table_name DROP COLUMN profileWeight"; | ||
mysqli_query($con, $sqlProfileWeightQuery) or die(mysqli_error($con)); | ||
$sqlProfileVeQuery = "ALTER TABLE $db_table_name DROP COLUMN profileVe"; | ||
mysqli_query($con, $sqlProfileVeQuery) or die(mysqli_error($con)); | ||
$sqlProfileFuelCostQuery = "ALTER TABLE $db_table_name DROP COLUMN profileFuelCost"; | ||
mysqli_query($con, $sqlProfileFuelCostQuery) or die(mysqli_error($con)); | ||
|
||
} | ||
|
||
// Split the raw logs table into per-month tables | ||
$sessionYears = mysqli_query($con, "SELECT DISTINCT CONCAT(YEAR(FROM_UNIXTIME(session/1000)), '_', DATE_FORMAT(FROM_UNIXTIME(session/1000),'%m')) as Suffix, YEAR(FROM_UNIXTIME(session/1000)) as Year, MONTH(FROM_UNIXTIME(session/1000)) as Month FROM $db_table"); | ||
while( $row = mysqli_fetch_assoc( $sessionYears ) ) { | ||
$suffix = $row['Suffix']; | ||
$year = $row['Year']; | ||
$month = $row['Month']; | ||
$new_table_name = "{$db_table}_test_{$suffix}"; | ||
$table_create_query = "CREATE TABLE $new_table_name SELECT * FROM $db_table WHERE YEAR(FROM_UNIXTIME(session/1000)) LIKE '$year' and MONTH(FROM_UNIXTIME(session/1000)) LIKE '$month'"; | ||
mysqli_query($con, $table_create_query) or die(mysqli_error($con)); | ||
} | ||
|
||
// Clear the raw_logs table; we still want it as a shell, just empty | ||
mysqli_query($con, "DELETE FROM $db_table") or die(mysqli_error($con)); | ||
?> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.