[chronojump] Select_MAX_AVG_MIN_EventsOfAType to have 3 in one SQL call. Used on run simple capture graph
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Select_MAX_AVG_MIN_EventsOfAType to have 3 in one SQL call. Used on run simple capture graph
- Date: Sun, 29 Aug 2021 17:31:28 +0000 (UTC)
commit 71e6e24acdf7a8428f54e72c7cbbc5dbe28c5706
Author: Xavier de Blas <xaviblas gmail com>
Date: Sun Aug 29 19:30:57 2021 +0200
Select_MAX_AVG_MIN_EventsOfAType to have 3 in one SQL call. Used on run simple capture graph
src/gui/usefulObjects.cs | 25 ++++++++++++++-----------
src/sqlite/session.cs | 11 ++++++++++-
2 files changed, 24 insertions(+), 12 deletions(-)
---
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index 65a20b861..299159228 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -197,23 +197,26 @@ public class PrepareEventGraphRunSimple {
string sqlSelect = "distance/time";
-
- personMAXAtSQLAllSessions = SqliteSession.SelectMAXEventsOfAType(true, -1, personID, table,
type, sqlSelect);
- personMAXAtSQL = SqliteSession.SelectMAXEventsOfAType(true, sessionID, personID, table, type,
sqlSelect);
- personMINAtSQL = SqliteSession.SelectMINEventsOfAType(true, sessionID, personID, table, type,
sqlSelect);
- sessionMAXAtSQL = SqliteSession.SelectMAXEventsOfAType(true, sessionID, -1, table, type,
sqlSelect);
- sessionMINAtSQL = SqliteSession.SelectMINEventsOfAType(true, sessionID, -1, table, type,
sqlSelect);
-
- //distancePersonAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, personID,
table, type, "distance");
- //distanceSessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, -1, table,
type, "distance");
//better to know speed like:
//SELECT AVG(distance/time) from run; than
//SELECT AVG(distance) / SELECT AVG(time)
//first is ok, because is the speed AVG
//2nd is not good because it tries to do an AVG of all distances and times
- personAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, personID, table, type,
sqlSelect);
- sessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, -1, table, type,
sqlSelect);
+ personMAXAtSQLAllSessions = SqliteSession.SelectMAXEventsOfAType(true, -1, personID, table,
type, sqlSelect); //right now, used only on the not-cairo solution
+
+ List<double> personStats = SqliteSession.Select_MAX_AVG_MIN_EventsOfAType(
+ true, sessionID, personID, table, type, sqlSelect);
+ personMAXAtSQL = personStats[0];
+ personAVGAtSQL = personStats[1];
+ personMINAtSQL = personStats[2];
+
+ List<double> sessionStats = SqliteSession.Select_MAX_AVG_MIN_EventsOfAType(
+ true, sessionID, -1, table, type, sqlSelect);
+ sessionMAXAtSQL = sessionStats[0];
+ sessionAVGAtSQL = sessionStats[1];
+ sessionMINAtSQL = sessionStats[2];
+
this.time = time;
this.speed = speed;
this.type = type;
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index 7a9495f89..2b3b09143 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -850,7 +850,16 @@ class SqliteSession : Sqlite
return selectEventsOfAType(dbconOpened, sessionID, personID,
table, type, valueToSelect, "MAX_AVG_MIN")[2];
}
- public static List<double> selectEventsOfAType(bool dbconOpened, int sessionID, int personID,
+
+ //to have the three in one call, much better, use this in new code
+ public static List<double> Select_MAX_AVG_MIN_EventsOfAType(bool dbconOpened, int sessionID, int
personID,
+ string table, string type, string valueToSelect)
+ {
+ return selectEventsOfAType(dbconOpened, sessionID, personID,
+ table, type, valueToSelect, "MAX_AVG_MIN");
+ }
+
+ private static List<double> selectEventsOfAType(bool dbconOpened, int sessionID, int personID,
string table, string type, string valueToSelect, string statistic)
{
if(!dbconOpened)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]