[chronojump] SqliteSession.selectEventsOfAType accepts events of type == "" (all)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] SqliteSession.selectEventsOfAType accepts events of type == "" (all)
- Date: Tue, 16 Jun 2020 18:38:54 +0000 (UTC)
commit 18cfe9fc7b46c5556435ddb44a955f77b69cf7ba
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Jun 16 20:36:50 2020 +0200
SqliteSession.selectEventsOfAType accepts events of type == "" (all)
src/sqlite/session.cs | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index 8caf5ff8..6bab2a73 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -805,6 +805,7 @@ class SqliteSession : Sqlite
//called from gui/event.cs for doing the graph
//we need to know the avg of events of a type (SJ, CMJ, free (pulse).. of a person, or of all persons
on the session
+ //from 2.0 type can be "" so all types
public static double SelectAVGEventsOfAType(bool dbconOpened, int sessionID, int personID, string
table, string type, string valueToSelect)
{
return selectEventsOfAType(dbconOpened, sessionID, personID, table, type, valueToSelect,
"AVG");
@@ -823,21 +824,34 @@ class SqliteSession : Sqlite
if(!dbconOpened)
Sqlite.Open();
- //if personIDString == -1, the applies for all persons
-
- string personIDString = "";
- if(personID != -1)
- personIDString = " AND personID = " + personID;
+ string connector = " WHERE "; //WHERE or AND
string sessionIDString = "";
if(sessionID != -1)
- sessionIDString = " AND sessionID = " + sessionID;
+ {
+ sessionIDString = connector + "sessionID = " + sessionID;
+ connector = " AND ";
+ }
+
+ string personIDString = "";
+ if(personID != -1)
+ {
+ personIDString = connector + "personID = " + personID;
+ connector = " AND ";
+ }
+
+ string typeString = "";
+ if(type != "")
+ {
+ typeString = connector + "type = \"" + type + "\"";
+ connector = " AND ";
+ }
dbcmd.CommandText = "SELECT " + statistic + "(" + valueToSelect + ")" +
" FROM " + table +
- " WHERE type = \"" + type + "\" " +
+ sessionIDString +
personIDString +
- sessionIDString;
+ typeString;
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]