diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2020-09-12 21:38:46 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-09-15 08:47:51 -0700 |
commit | a7bed157b5672529a9f166c9bb2fa6a7cc3f81ce (patch) | |
tree | ec9935be26ee8c28e88b20b2ac80673f032ee66d | |
parent | 23efcef58a7c24124c690d2e075522a696a43baa (diff) | |
download | subsurface-a7bed157b5672529a9f166c9bb2fa6a7cc3f81ce.tar.gz |
Grab the first gas on Shearwater import
The logic to retrieve gas changes from Shearwater cloud database is
detecting only when the O2/He chnages. This change will grab the initial
gas. (Problem was only shown when there was a gas changee in the log, so
cingle cylinder dives were working fine.)
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
-rw-r--r-- | core/import-shearwater.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/import-shearwater.c b/core/import-shearwater.c index 7047f04d6..0e4c7f67a 100644 --- a/core/import-shearwater.c +++ b/core/import-shearwater.c @@ -332,6 +332,7 @@ static int shearwater_cloud_dive(void *param, int columns, char **data, char **c char get_profile_template[] = "select currentTime,currentDepth,waterTemp,averagePPO2,currentNdl,CNSPercent,decoCeiling,firstStopDepth,firstStopTime from dive_log_records where diveLogId=%ld"; char get_profile_template_ai[] = "select currentTime,currentDepth,waterTemp,averagePPO2,currentNdl,CNSPercent,decoCeiling,aiSensor0_PressurePSI,aiSensor1_PressurePSI,firstStopDepth,firstStopTime from dive_log_records where diveLogId = %ld and currentTime > 0"; char get_cylinder_template[] = "select fractionO2 / 100,fractionHe / 100 from dive_log_records where diveLogId = %ld group by fractionO2,fractionHe"; + char get_first_gas_template[] = "select currentTime, fractionO2 / 100, fractionHe / 100 from dive_log_records where diveLogId = %ld limit 1"; char get_changes_template[] = "select a.currentTime,a.fractionO2 / 100,a.fractionHe /100 from dive_log_records as a,dive_log_records as b where (a.id - 1) = b.id and (a.fractionO2 != b.fractionO2 or a.fractionHe != b.fractionHe) and a.diveLogId=b.divelogId and a.diveLogId = %ld and a.fractionO2 > 0 and b.fractionO2 > 0"; char get_mode_template[] = "select distinct currentCircuitSetting from dive_log_records where diveLogId = %ld"; char get_buffer[1024]; @@ -421,6 +422,13 @@ static int shearwater_cloud_dive(void *param, int columns, char **data, char **c return 1; } + snprintf(get_buffer, sizeof(get_buffer) - 1, get_first_gas_template, dive_id); + retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, state, NULL); + if (retval != SQLITE_OK) { + fprintf(stderr, "%s", "Database query shearwater_changes failed.\n"); + return 1; + } + snprintf(get_buffer, sizeof(get_buffer) - 1, get_changes_template, dive_id); retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, state, NULL); if (retval != SQLITE_OK) { |