[chronojump] run graph update does not call SQL
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] run graph update does not call SQL
- Date: Mon, 11 Nov 2013 13:39:16 +0000 (UTC)
commit 8237cfda9bc23cfecb43d061465842decdab2092
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Nov 11 14:38:25 2013 +0100
run graph update does not call SQL
src/execute/run.cs | 7 ++++-
src/exportSession.cs | 2 +-
src/gui/chronojump.cs | 4 +-
src/gui/eventExecute.cs | 56 +++++++++++++++++++--------------------------
src/gui/person.cs | 2 +-
src/gui/run.cs | 2 +-
src/gui/usefulObjects.cs | 31 ++++++++++++++++++++++++-
src/report.cs | 2 +-
src/server.cs | 2 +-
src/sqlite/run.cs | 10 +++++--
10 files changed, 73 insertions(+), 45 deletions(-)
---
diff --git a/src/execute/run.cs b/src/execute/run.cs
index d65f6b2..4b7e282 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -409,8 +409,11 @@ Log.WriteLine("MANAGE(3)!!!!");
description = "P = " + Util.TrimDecimals ( (weight * 9.8 * distanceMeters /
time).ToString(), pDN) + " (Watts)";
} else if(type == "Gesell-DBT")
description = "0";
+
+
+ string table = Constants.RunTable;
- uniqueID = SqliteRun.Insert(false, Constants.RunTable, "NULL", personID, sessionID,
+ uniqueID = SqliteRun.Insert(false, table, "NULL", personID, sessionID,
type, distance, time, description,
Util.BoolToNegativeInt(simulated),
!startIn //initialSpeed true if not startIn
@@ -424,7 +427,7 @@ Log.WriteLine("MANAGE(3)!!!!");
fakeButtonFinished.Click();
//app1.PrepareRunSimpleGraph(time, distance/time);
- PrepareEventGraphRunSimpleObject = new PrepareEventGraphRunSimple(time, distance/time);
+ PrepareEventGraphRunSimpleObject = new PrepareEventGraphRunSimple(time, distance/time,
sessionID, personID, table, type);
needUpdateGraphType = eventType.RUN;
needUpdateGraph = true;
diff --git a/src/exportSession.cs b/src/exportSession.cs
index c3d75b3..534b2dc 100644
--- a/src/exportSession.cs
+++ b/src/exportSession.cs
@@ -154,7 +154,7 @@ public class ExportSession
myPersons = SqlitePersonSession.SelectCurrentSessionPersons(mySession.UniqueID);
myJumps= SqliteJump.SelectJumps(false, mySession.UniqueID, -1, "", "");
myJumpsRj = SqliteJumpRj.SelectJumps(mySession.UniqueID, -1, "", "");
- myRuns= SqliteRun.SelectRuns(mySession.UniqueID, -1, "");
+ myRuns= SqliteRun.SelectRuns(false, mySession.UniqueID, -1, "");
myRunsInterval = SqliteRunInterval.SelectRuns(mySession.UniqueID, -1, "");
myReactionTimes = SqliteReactionTime.SelectReactionTimes(mySession.UniqueID, -1);
myPulses = SqlitePulse.SelectPulses(mySession.UniqueID, -1);
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 4247c5a..13e0454 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -1621,7 +1621,7 @@ public partial class ChronoJumpWindow
}
private void fillTreeView_runs (string filter) {
- string [] myRuns = SqliteRun.SelectRuns(currentSession.UniqueID, -1, "");
+ string [] myRuns = SqliteRun.SelectRuns(false, currentSession.UniqueID, -1, "");
myTreeViewRuns.Fill(myRuns, filter);
expandOrMinimizeTreeView((TreeViewEvent) myTreeViewRuns, treeview_runs);
@@ -4350,7 +4350,7 @@ Console.WriteLine("X");
break;
case EventType.Types.RUN:
if(lastRunIsSimple)
- PrepareRunSimpleGraph(currentRun.Time, currentRun.Speed);
+
PrepareRunSimpleGraph(currentEventExecute.PrepareEventGraphRunSimpleObject);
else {
RunType runType =
SqliteRunIntervalType.SelectAndReturnRunIntervalType(currentRunInterval.Type, false);
double distanceTotal =
Util.GetRunITotalDistance(currentRunInterval.DistanceInterval,
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index 50beb39..dfdeded 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -700,7 +700,7 @@ Log.WriteLine("Preparing reactive A");
// run simple
- public void PrepareRunSimpleGraph(double time, double speed)
+ public void PrepareRunSimpleGraph(PrepareEventGraphRunSimple eventGraph)
{
//check graph properties window is not null (propably user has closed it with the DeleteEvent
//then create it, but not show it
@@ -712,21 +712,6 @@ Log.WriteLine("Preparing reactive A");
if(eventGraphConfigureWin.RunsTimeActive)
paintTime = true;
- //obtain data
- string [] runs = SqliteRun.SelectRuns(currentSession.UniqueID, event_execute_personID,
event_execute_eventType);
-
- double timePersonAVG = SqliteSession.SelectAVGEventsOfAType(false, currentSession.UniqueID,
event_execute_personID, event_execute_tableName, event_execute_eventType, "time");
- double timeSessionAVG = SqliteSession.SelectAVGEventsOfAType(false, currentSession.UniqueID,
-1, event_execute_tableName, event_execute_eventType, "time");
-
- //double distancePersonAVG = SqliteSession.SelectAVGEventsOfAType(false,
currentSession.UniqueID, event_execute_personID, event_execute_tableName, event_execute_eventType,
"distance");
- //double distanceSessionAVG = SqliteSession.SelectAVGEventsOfAType(false,
currentSession.UniqueID, -1, event_execute_tableName, event_execute_eventType, "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
- double speedPersonAVG = SqliteSession.SelectAVGEventsOfAType(false, currentSession.UniqueID,
event_execute_personID, event_execute_tableName, event_execute_eventType, "distance/time");
- double speedSessionAVG = SqliteSession.SelectAVGEventsOfAType(false, currentSession.UniqueID,
-1, event_execute_tableName, event_execute_eventType, "distance/time");
double maxValue = 0;
double minValue = 0;
@@ -736,16 +721,18 @@ Log.WriteLine("Preparing reactive A");
//if max value of graph is automatic
if(eventGraphConfigureWin.Max == -1) {
if(paintTime) {
- maxValue = Util.GetMax(time.ToString() + "=" + timePersonAVG.ToString() + "="
+ timeSessionAVG.ToString());
- foreach(string myStr in runs) {
+ maxValue = Util.GetMax(eventGraph.time.ToString() + "=" +
+ eventGraph.timePersonAVGAtSQL.ToString() + "=" +
eventGraph.timeSessionAVGAtSQL.ToString());
+ foreach(string myStr in eventGraph.runsAtSQL) {
string [] run = myStr.Split(new char[] {':'});
if(Convert.ToDouble(run[6]) > maxValue)
maxValue = Convert.ToDouble(run[6]);
}
}
else { //paint speed
- maxValue = Util.GetMax(speed.ToString() + "=" + speedPersonAVG.ToString() +
"=" + speedSessionAVG.ToString());
- foreach(string myStr in runs) {
+ maxValue = Util.GetMax(eventGraph.speed.ToString() + "=" +
+ eventGraph.speedPersonAVGAtSQL.ToString() + "=" +
eventGraph.speedSessionAVGAtSQL.ToString());
+ foreach(string myStr in eventGraph.runsAtSQL) {
string [] run = myStr.Split(new char[] {':'});
double mySpeed = Convert.ToDouble(Util.GetSpeed(run[5], run[6],
true));
if(mySpeed > maxValue)
@@ -760,16 +747,18 @@ Log.WriteLine("Preparing reactive A");
//if min value of graph is automatic
if(eventGraphConfigureWin.Min == -1) {
if(paintTime) {
- minValue = Util.GetMin(time.ToString() + "=" + timePersonAVG.ToString() + "="
+ timeSessionAVG.ToString());
- foreach(string myStr in runs) {
+ minValue = Util.GetMin(eventGraph.time.ToString() + "=" +
+ eventGraph.timePersonAVGAtSQL.ToString() + "=" +
eventGraph.timeSessionAVGAtSQL.ToString());
+ foreach(string myStr in eventGraph.runsAtSQL) {
string [] run = myStr.Split(new char[] {':'});
if(Convert.ToDouble(run[6]) < minValue)
minValue = Convert.ToDouble(run[6]);
}
}
else {
- minValue = Util.GetMin(speed.ToString() + "=" + speedPersonAVG.ToString() +
"=" + speedSessionAVG.ToString());
- foreach(string myStr in runs) {
+ minValue = Util.GetMin(eventGraph.speed.ToString() + "=" +
+ eventGraph.speedPersonAVGAtSQL.ToString() + "=" +
eventGraph.speedSessionAVGAtSQL.ToString());
+ foreach(string myStr in eventGraph.runsAtSQL) {
string [] run = myStr.Split(new char[] {':'});
double mySpeed = Convert.ToDouble(Util.GetSpeed(run[5], run[6],
true));
if(mySpeed < minValue)
@@ -784,12 +773,17 @@ Log.WriteLine("Preparing reactive A");
//paint graph
if(paintTime)
- paintRunSimple (event_execute_drawingarea, pen_rojo, runs, time, timePersonAVG,
timeSessionAVG, maxValue, minValue, topMargin, bottomMargin);
+ paintRunSimple (event_execute_drawingarea, pen_rojo, eventGraph.runsAtSQL,
+ eventGraph.time, eventGraph.timePersonAVGAtSQL,
eventGraph.timeSessionAVGAtSQL,
+ maxValue, minValue, topMargin, bottomMargin);
else //paint speed
- paintRunSimple (event_execute_drawingarea, pen_azul_claro, runs, speed,
speedPersonAVG, speedSessionAVG, maxValue, minValue, topMargin, bottomMargin);
+ paintRunSimple (event_execute_drawingarea, pen_azul_claro, eventGraph.runsAtSQL,
+ eventGraph.speed, eventGraph.speedPersonAVGAtSQL,
eventGraph.speedSessionAVGAtSQL,
+ maxValue, minValue, topMargin, bottomMargin);
//printLabels
- printLabelsRunSimple (time, timePersonAVG, timeSessionAVG, speed, speedPersonAVG,
speedSessionAVG);
+ printLabelsRunSimple (eventGraph.time, eventGraph.timePersonAVGAtSQL,
eventGraph.timeSessionAVGAtSQL,
+ eventGraph.speed, eventGraph.speedPersonAVGAtSQL,
eventGraph.speedSessionAVGAtSQL);
// -- refresh
event_execute_drawingarea.QueueDraw();
@@ -1824,11 +1818,9 @@ Log.WriteLine("Preparing reactive A");
}
break;
case EventType.Types.RUN:
- if(thisRunIsSimple) {
- PrepareRunSimpleGraph(
-
currentEventExecute.PrepareEventGraphRunSimpleObject.time,
-
currentEventExecute.PrepareEventGraphRunSimpleObject.speed);
- } else {
+ if(thisRunIsSimple)
+
PrepareRunSimpleGraph(currentEventExecute.PrepareEventGraphRunSimpleObject);
+ else {
bool volumeOnHere = true;
//do not play good or bad sounds at RSA because we need to hear the
GO sound
if(currentRunIntervalType.IsRSA)
diff --git a/src/gui/person.cs b/src/gui/person.cs
index 2b72337..f61a9d2 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -1645,7 +1645,7 @@ public class PersonAddModifyWindow
double weight = (double) spinbutton_weight.Value;
//convert margarias (it's power is calculated using weight and it's written on description)
- string [] myMargarias = SqliteRun.SelectRuns(currentSession.UniqueID, currentPerson.UniqueID,
"Margaria");
+ string [] myMargarias = SqliteRun.SelectRuns(false, currentSession.UniqueID,
currentPerson.UniqueID, "Margaria");
foreach(string myStr in myMargarias) {
string [] margaria = myStr.Split(new char[] {':'});
Run mRun = SqliteRun.SelectRunData(Convert.ToInt32(margaria[1]), false);
diff --git a/src/gui/run.cs b/src/gui/run.cs
index 2f366e8..320aefc 100644
--- a/src/gui/run.cs
+++ b/src/gui/run.cs
@@ -1428,7 +1428,7 @@ public class RunsMoreWindow : EventMoreWindow
}
protected override string [] findTestTypesInSessions() {
- return SqliteRun.SelectRuns(-1, -1, selectedEventName);
+ return SqliteRun.SelectRuns(false, -1, -1, selectedEventName);
}
void on_button_cancel_clicked (object o, EventArgs args)
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index 6c09d85..61189d7 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -135,15 +135,44 @@ public class PrepareEventGraphJumpReactive {
}
public class PrepareEventGraphRunSimple {
+ //sql data of previous runs to plot graph and show stats at bottom
+ public string [] runsAtSQL;
+ public double timePersonAVGAtSQL;
+ public double timeSessionAVGAtSQL;
+ public double speedPersonAVGAtSQL;
+ public double speedSessionAVGAtSQL;
+
public double time;
public double speed;
public PrepareEventGraphRunSimple() {
}
- public PrepareEventGraphRunSimple(double time, double speed) {
+ public PrepareEventGraphRunSimple(double time, double speed, int sessionID, int personID, string
table, string type)
+ {
+ Sqlite.Open();
+
+ //obtain data
+ runsAtSQL = SqliteRun.SelectRuns(true, sessionID, personID, type);
+
+ timePersonAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, personID, table,
type, "time");
+ timeSessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, -1, table, type,
"time");
+
+ //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
+ speedPersonAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, personID, table,
type, "distance/time");
+ speedSessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, -1, table, type,
"distance/time");
+
+
this.time = time;
this.speed = speed;
+
+ Sqlite.Close();
}
~PrepareEventGraphRunSimple() {}
diff --git a/src/report.cs b/src/report.cs
index cf4ce9c..1dbb94b 100644
--- a/src/report.cs
+++ b/src/report.cs
@@ -126,7 +126,7 @@ public class Report : ExportSession
myJumpsRj = SqliteJumpRj.SelectJumps(sessionID, -1, "", "");
}
if(ShowSimpleRuns) {
- myRuns= SqliteRun.SelectRuns(sessionID, -1, "");
+ myRuns= SqliteRun.SelectRuns(false, sessionID, -1, "");
}
if (ShowIntervalRuns) {
myRunsInterval = SqliteRunInterval.SelectRuns(sessionID, -1, "");
diff --git a/src/server.cs b/src/server.cs
index 648f37f..5af4a01 100644
--- a/src/server.cs
+++ b/src/server.cs
@@ -365,7 +365,7 @@ public class Server
countE = 0;
countS = 0;
- string [] runs = SqliteRun.SelectRuns(currentSession.UniqueID,
person.UniqueID, "");
+ string [] runs = SqliteRun.SelectRuns(false, currentSession.UniqueID,
person.UniqueID, "");
Sqlite.Open();
foreach(string myRun in runs) {
string [] js = myRun.Split(new char[] {':'});
diff --git a/src/sqlite/run.cs b/src/sqlite/run.cs
index f089e77..24d33e8 100644
--- a/src/sqlite/run.cs
+++ b/src/sqlite/run.cs
@@ -89,8 +89,11 @@ class SqliteRun : Sqlite
//if all sessions, put -1 in sessionID
//if all persons, put -1 in personID
//if all types, put "" in filterType
- public static string[] SelectRuns(int sessionID, int personID, string filterType)
+ public static string[] SelectRuns(bool dbconOpened, int sessionID, int personID, string filterType)
{
+ if(!dbconOpened)
+ dbcon.Open();
+
string tp = Constants.PersonTable;
string filterSessionString = "";
@@ -105,7 +108,6 @@ class SqliteRun : Sqlite
if(filterType != "")
filterTypeString = " AND run.type == '" + filterType + "' " ;
- dbcon.Open();
dbcmd.CommandText = "SELECT " + tp + ".name, run.* " +
" FROM " + tp + ", run " +
" WHERE " + tp + ".uniqueID == run.personID" +
@@ -141,7 +143,9 @@ class SqliteRun : Sqlite
}
reader.Close();
- dbcon.Close();
+
+ if(!dbconOpened)
+ dbcon.Close();
string [] myRuns = new string[count];
count =0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]