[chronojump] new JumpRj constructor and DataReaderToJumpRj allows to directly use Max, Avg values on Sqlite
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] new JumpRj constructor and DataReaderToJumpRj allows to directly use Max, Avg values on Sqlite
- Date: Mon, 6 Sep 2021 14:26:30 +0000 (UTC)
commit c16dc513086b12d3c524814e700f853625d7bdfb
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Sep 6 16:25:54 2021 +0200
new JumpRj constructor and DataReaderToJumpRj allows to directly use Max,Avg values on Sqlite
src/jump.cs | 81 ++++++++++++++++++++++++++++++++++++++++++++++------
src/sqlite/jumpRj.cs | 8 ++++--
2 files changed, 78 insertions(+), 11 deletions(-)
---
diff --git a/src/jump.cs b/src/jump.cs
index 5edaf7e69..609b7b347 100644
--- a/src/jump.cs
+++ b/src/jump.cs
@@ -154,8 +154,47 @@ public class JumpRj : Jump
string limited; //the teorically values, eleven jumps: "11=J" (time recorded in "time"), 10 seconds:
"10=T" (jumps recorded in jumps)
bool jumpsLimited;
private string angleString;
-
+
+ bool calculatedStats;
+ private double tvMax;
+ private double tcMax;
+ private double tvAvg;
+ private double tcAvg;
+
+
public JumpRj() {
+ calculatedStats = false;
+ }
+
+ public JumpRj(int uniqueID, int personID, int sessionID, string type,
+ double tvMax, double tcMax,
+ double fall, double weight, string description,
+ double tvAvg, double tcAvg,
+ string tvString, string tcString,
+ int jumps, double time, string limited,
+ string angleString, int simulated, string datetime)
+ {
+ this.uniqueID = uniqueID;
+ this.personID = personID;
+ this.sessionID = sessionID;
+ this.type = type;
+ this.tvMax = tvMax;
+ this.tcMax = tcMax;
+ this.fall = fall;
+ this.weight = weight;
+ this.description = description;
+ this.tvAvg = tvAvg;
+ this.tcAvg = tcAvg;
+ this.tvString = tvString;
+ this.tcString = tcString;
+ this.jumps = jumps;
+ this.time = time;
+ this.limited = limited;
+ this.angleString = angleString;
+ this.simulated = simulated;
+ this.datetime = datetime;
+
+ calculatedStats = true;
}
//after inserting database (SQL)
@@ -178,6 +217,8 @@ public class JumpRj : Jump
this.angleString = angleString;
this.simulated = simulated;
this.datetime = datetime;
+
+ calculatedStats = false;
}
//used to select a jump at SqliteJumpRj.SelectJumpData and at Sqlite.convertTables
@@ -201,6 +242,8 @@ public class JumpRj : Jump
this.angleString = eventString[16];
this.simulated = Convert.ToInt32(eventString[17]);
this.datetime = eventString[18];
+
+ calculatedStats = false;
}
@@ -237,25 +280,45 @@ public class JumpRj : Jump
{
get { return SqliteJumpType.HasFall("jumpRjType", type); } //jumpRjType is the table name
}
-
+
public double TvMax
{
- get { return Util.GetMax (tvString); }
+ get {
+ if(! calculatedStats)
+ tvMax = Util.GetMax (tvString);
+
+ return tvMax;
+ }
}
-
+
public double TcMax
{
- get { return Util.GetMax (tcString); }
+ get {
+ if(! calculatedStats)
+ tcMax = Util.GetMax (tcString);
+
+ return tcMax;
+ }
}
-
+
public double TvAvg
{
- get { return Util.GetAverage (tvString); }
+ get {
+ if(! calculatedStats)
+ tvAvg = Util.GetAverage (tvString);
+
+ return tvAvg;
+ }
}
-
+
public double TcAvg
{
- get { return Util.GetAverage (tcString); }
+ get {
+ if(! calculatedStats)
+ tcAvg = Util.GetAverage (tcString);
+
+ return tcAvg;
+ }
}
diff --git a/src/sqlite/jumpRj.cs b/src/sqlite/jumpRj.cs
index 246ea2986..fcf16b4f3 100644
--- a/src/sqlite/jumpRj.cs
+++ b/src/sqlite/jumpRj.cs
@@ -283,11 +283,15 @@ class SqliteJumpRj : SqliteJump
Convert.ToInt32(reader[1].ToString()), //jumpRj.personID
Convert.ToInt32(reader[2].ToString()), //jumpRj.sessionID
reader[3].ToString(), //jumpRj.type
- Util.ChangeDecimalSeparator(reader[11].ToString()), //tvString
- Util.ChangeDecimalSeparator(reader[12].ToString()), //tcString
+ Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())),
//tvMax
+ Convert.ToDouble(Util.ChangeDecimalSeparator(reader[5].ToString())),
//tcMax
Convert.ToDouble(Util.ChangeDecimalSeparator(reader[6].ToString())), //fall
Convert.ToDouble(Util.ChangeDecimalSeparator(reader[7].ToString())),
//weight
reader[8].ToString(), //description
+ Convert.ToDouble(Util.ChangeDecimalSeparator(reader[9].ToString())),
//tvAvg
+ Convert.ToDouble(Util.ChangeDecimalSeparator(reader[10].ToString())),
//tcAvg
+ Util.ChangeDecimalSeparator(reader[11].ToString()), //tvString
+ Util.ChangeDecimalSeparator(reader[12].ToString()), //tcString
Convert.ToInt32(reader[13].ToString()), //jumps
Convert.ToDouble(Util.ChangeDecimalSeparator(reader[14].ToString())), //time
reader[15].ToString(), //limited
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]