[chronojump] Fixed: Repetition wrong sorting in encoder (on analyze currentPerson, currentSession)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixed: Repetition wrong sorting in encoder (on analyze currentPerson, currentSession)
- Date: Mon, 28 Feb 2022 16:39:35 +0000 (UTC)
commit 6faf88ffd6af8871d549b0018489ff3e5a177509
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Feb 28 17:38:56 2022 +0100
Fixed: Repetition wrong sorting in encoder (on analyze currentPerson, currentSession)
src/gui/app1/encoder.cs | 36 ++++++++---------
src/gui/encoderSelectRepetitions.cs | 6 +--
src/sqlite/encoder.cs | 77 +++++++++++++++++++++++++------------
src/sqlite/main.cs | 4 +-
src/sqlite/personSession.cs | 4 +-
src/sqlite/session.cs | 4 +-
6 files changed, 80 insertions(+), 51 deletions(-)
---
diff --git a/src/gui/app1/encoder.cs b/src/gui/app1/encoder.cs
index b6761e194..f83f8b088 100644
--- a/src/gui/app1/encoder.cs
+++ b/src/gui/app1/encoder.cs
@@ -716,7 +716,7 @@ public partial class ChronoJumpWindow
ArrayList arrayTemp = SqliteEncoder.Select(false, -1, currentPerson.UniqueID, -1, encGI,
getExerciseIDFromEncoderCombo(exerciseCombos.CAPTURE), "curve",
EncoderSQL.Eccons.ALL, getLateralityFromGui(true),
- false, false);
+ false, false, false);
maxPowerIntersession = 0;
maxSpeedIntersession = 0;
@@ -1632,7 +1632,7 @@ public partial class ChronoJumpWindow
EncoderSQL eSQL = new EncoderSQL();
try {
eSQL = (EncoderSQL) SqliteEncoder.Select(dbconOpened, uniqueID, 0, 0,
Constants.EncoderGI.ALL,
- -1, "", EncoderSQL.Eccons.ALL, "", false, true)[0];
+ -1, "", EncoderSQL.Eccons.ALL, "", false, true, false)[0];
} catch {
eSQLfound = false;
LogB.Warning("Catched! seems it's already deleted");
@@ -1671,7 +1671,7 @@ public partial class ChronoJumpWindow
return SqliteEncoder.Select(
false, -1, currentPerson.UniqueID, currentSession.UniqueID, getEncoderGI(),
-1, "signal", EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, false);
}
//this is called when user clicks on load signal
void on_button_encoder_load_signal_clicked (object o, EventArgs args) {
@@ -1762,7 +1762,7 @@ public partial class ChronoJumpWindow
ArrayList data = SqliteEncoder.Select(
false, uniqueID, currentPerson.UniqueID, currentSession.UniqueID,
Constants.EncoderGI.ALL,
-1, "signal", EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, false);
bool success = false;
foreach(EncoderSQL eSQL in data) { //it will run only one time
@@ -1888,7 +1888,7 @@ public partial class ChronoJumpWindow
//1) select set
int setID = genericWin.TreeviewSelectedUniqueID;
EncoderSQL eSQL_set = (EncoderSQL) SqliteEncoder.Select(true, setID, 0, 0,
Constants.EncoderGI.ALL,
- -1, "", EncoderSQL.Eccons.ALL, "", false, true)[0];
+ -1, "", EncoderSQL.Eccons.ALL, "", false, true, false)[0];
//2) if changed comment, update SQL, and update treeview
//first remove conflictive characters
@@ -1922,7 +1922,7 @@ public partial class ChronoJumpWindow
foreach (EncoderSignalCurve esc in linkedReps)
{
EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(true, esc.curveID, 0, 0,
Constants.EncoderGI.ALL,
- -1, "curve", EncoderSQL.Eccons.ALL, "", false, true)[0];
+ -1, "curve", EncoderSQL.Eccons.ALL, "", false, true,
false)[0];
eSQLChangedPerson = eSQL.ChangePerson(idName);
SqliteEncoder.Update(true, eSQLChangedPerson);
@@ -1960,7 +1960,7 @@ public partial class ChronoJumpWindow
else {
EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(
false, signalID, 0, 0, Constants.EncoderGI.ALL,
- -1, "signal", EncoderSQL.Eccons.ALL, "", false, true)[0];
+ -1, "signal", EncoderSQL.Eccons.ALL, "", false, true, false)[0];
//delete signal and related curves (both from SQL and files)
encoderSignalDelete(eSQL.GetFullURL(false), signalID); //don't convertPathToR
@@ -2025,7 +2025,7 @@ public partial class ChronoJumpWindow
//select related curves to find URL
ArrayList array = SqliteEncoder.Select(
false, esc.curveID, -1, -1, Constants.EncoderGI.ALL,
- -1, "curve", EncoderSQL.Eccons.ALL, "", false, true);
+ -1, "curve", EncoderSQL.Eccons.ALL, "", false, true, false);
if (array != null && array.Count > 0)
{
@@ -2787,7 +2787,7 @@ public partial class ChronoJumpWindow
{
EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(
false, Convert.ToInt32(encoderSignalUniqueID), 0, 0, Constants.EncoderGI.ALL,
- -1, "signal", EncoderSQL.Eccons.ALL, "", false, true)[0];
+ -1, "signal", EncoderSQL.Eccons.ALL, "", false, true, false)[0];
//delete signal and related curves (both from SQL and files)
encoderSignalDelete(eSQL.GetFullURL(false), Convert.ToInt32(encoderSignalUniqueID));
@@ -2897,7 +2897,7 @@ public partial class ChronoJumpWindow
dbconOpened, -1, currentPerson.UniqueID, currentSession.UniqueID,
getEncoderGI(),
getExerciseIDFromEncoderCombo(exerciseCombos.ANALYZE),
"curve", EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, true);
updateComboEncoderAnalyzeCurveNumSavedReps(data);
} //interperson and intersession modes don't use combo_encoder_analyze_curve_num_combo
@@ -3143,7 +3143,7 @@ public partial class ChronoJumpWindow
ArrayList data = SqliteEncoder.Select(
false, -1, currentPerson.UniqueID, currentSession.UniqueID,
getEncoderGI(),
getExerciseIDFromEncoderCombo(exerciseCombos.ANALYZE), "curve",
EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, true);
if(data.Count == 0) {
new DialogMessage(Constants.MessageTypes.WARNING,
@@ -3502,7 +3502,7 @@ public partial class ChronoJumpWindow
false, -1, currentPerson.UniqueID, currentSession.UniqueID,
getEncoderGI(),
getExerciseIDFromEncoderCombo(exerciseCombos.ANALYZE),
"curve", ecconSelect, "",
- false, true);
+ false, true, true);
}
else if(radio_encoder_analyze_groupal_current_session.Active)
{
@@ -3515,7 +3515,7 @@ public partial class ChronoJumpWindow
getExerciseIDFromEncoderCombo(exerciseCombos.ANALYZE),
"curve", EncoderSQL.Eccons.ALL, "",
false, //onlyActive=false. Means: all saved
repetitions
- true);
+ true, true);
foreach(EncoderSQL eSQL in dataPre) {
eSQL.status = "active"; //force all to be active on
interperson
data.Add(eSQL);
@@ -3535,7 +3535,7 @@ public partial class ChronoJumpWindow
getExerciseIDFromEncoderCombo(exerciseCombos.ANALYZE),
"curve", EncoderSQL.Eccons.ALL, "",
false, //onlyActive=false. Means: all saved
repetitions
- true);
+ true, true);
foreach(EncoderSQL eSQL in dataPre) {
string comboWeightsValue =
UtilGtk.ComboGetActive(combo_encoder_analyze_weights);
if(check_encoder_intersession_x_is_date.Active &&
@@ -5285,10 +5285,10 @@ public partial class ChronoJumpWindow
//1 select if there gravitatory sets done with this exercise
bool gravitatoryCaptured = (SqliteEncoder.Select (false, -1, -1, -1,
Constants.EncoderGI.GRAVITATORY,
ex.UniqueID, "all", EncoderSQL.Eccons.ALL, "",
- false, true).Count > 0);
+ false, true, false).Count > 0);
bool inertialCaptured = (SqliteEncoder.Select (false, -1, -1, -1,
Constants.EncoderGI.INERTIAL,
ex.UniqueID, "all", EncoderSQL.Eccons.ALL, "",
- false, true).Count > 0);
+ false, true, false).Count > 0);
button_radio_encoder_exercise_help.Visible = false;
button_radio_encoder_exercise_help_message = "";
@@ -7784,7 +7784,7 @@ public partial class ChronoJumpWindow
ArrayList array = SqliteEncoder.Select(
true, Convert.ToInt32(encoderSignalUniqueID), 0, 0, getEncoderGI(),
-1, "", EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, true);
if(array.Count == 0)
return;
@@ -7794,7 +7794,7 @@ public partial class ChronoJumpWindow
ArrayList data = SqliteEncoder.Select(
true, -1, currentPerson.UniqueID, currentSession.UniqueID, getEncoderGI(),
-1, "curve", EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, true);
bool deletedUserCurves = false;
foreach(EncoderSQL eSQL in data)
diff --git a/src/gui/encoderSelectRepetitions.cs b/src/gui/encoderSelectRepetitions.cs
index 188addeb3..7ce4cd7e1 100644
--- a/src/gui/encoderSelectRepetitions.cs
+++ b/src/gui/encoderSelectRepetitions.cs
@@ -190,7 +190,7 @@ public class EncoderSelectRepetitionsIndividualCurrentSession : EncoderSelectRep
data = SqliteEncoder.Select(
false, -1, currentPerson.UniqueID, currentSession.UniqueID, encoderGI,
exerciseID, "curve", EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, true);
}
protected override void createBigArray()
@@ -321,7 +321,7 @@ public class EncoderSelectRepetitionsIndividualCurrentSession : EncoderSelectRep
ArrayList data = SqliteEncoder.Select(
false, -1, currentPerson.UniqueID, currentSession.UniqueID, encoderGI,
exerciseID, "curve", EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, true);
//update on database the curves that have been selected/deselected
//doing it as a transaction: FAST
@@ -593,7 +593,7 @@ public class EncoderSelectRepetitionsGroupalCurrentSession : EncoderSelectRepeti
ArrayList eSQLarray = SqliteEncoder.Select(
false, -1, p.UniqueID, currentSession.UniqueID, encoderGI,
exerciseID, "curve", EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, true);
int allCurves = eSQLarray.Count;
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index 6d664449b..1904365ae 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Copyright (C) 2004-2020 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2004-2022 Xavier de Blas <xaviblas gmail com>
*/
using System;
@@ -187,29 +187,38 @@ class SqliteEncoder : Sqlite
LogB.SQL("Ended transaction");
return countActive;
}
-
- //pass uniqueID value and then will return one record. do like this:
- //EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, myUniqueID, 0, 0, 0, "",
EncoderSQL.Eccons.ALL, false, true)[0];
-
- //WARNING because SqliteEncoder.Select may not return nothing, and then cannot be assigned to eSQL
- //see: delete_encoder_curve(bool dbconOpened, int uniqueID)
- //and: manageCurvesOfThisSignal
- //
- //don't care for the 0, 0, 0 because selection will be based on the myUniqueID and only one row will
be returned
- //or
- //pass uniqueID==-1 and personID, sessionID, signalOrCurve values, and will return some records
- //personID can be -1 to get all on that session
- //sessionID can be -1 to get all sessions
- //exerciseID can be -1 to get all exercises
- //signalOrCurve can be "all"
-
- //orderIDascendent is good for all the situations except when we want to convert from 1.05 to 1.06
- //in that conversion, we want first the last ones, and later the previous
- // (to delete them if they are old copies)
+
+ /*
+ SqliteEncoder.Select
+ pass uniqueID value and then will return one record. do like this:
+ EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, myUniqueID, 0, 0, 0, "",
EncoderSQL.Eccons.ALL, false, true)[0];
+
+ WARNING because SqliteEncoder.Select may not return nothing, and then cannot be assigned to eSQL
+ see: delete_encoder_curve(bool dbconOpened, int uniqueID)
+ and: manageCurvesOfThisSignal
+
+ don't care for the 0, 0, 0 because selection will be based on the myUniqueID and only one row
will be returned
+ or
+ pass uniqueID==-1 and personID, sessionID, signalOrCurve values, and will return some records
+ personID can be -1 to get all on that session
+ sessionID can be -1 to get all sessions
+ exerciseID can be -1 to get all exercises
+ signalOrCurve can be "all"
+
+ orderIDascendent is good for all the situations except when we want to convert from 1.05 to 1.06
+ in that conversion, we want first the last ones, and later the previous
+ (to delete them if they are old copies)
+
+ orderRepsByPosInSet uses encoderSignalCurve. encoder reps uniqueIDs are not correctly ordered by
set,
+ eg if you save only the best (maybe the 4th), will have uniqueID 1, and then if you save it all,
+ then they will be saved as 2, 3, (4 not saved becuase it is already one), 4, 5, ... So 4th in
order will be 1
+ orderRepsByPosInSet fixes this problem. this is used eg. in analyze session to sort them correctly
+ */
public static ArrayList Select (
bool dbconOpened, int uniqueID, int personID, int sessionID, Constants.EncoderGI
encoderGI,
int exerciseID, string signalOrCurve, EncoderSQL.Eccons ecconSelect, string
lateralityEnglish,
- bool onlyActive, bool orderIDascendent)
+ bool onlyActive, bool orderIDascendent,
+ bool orderRepsByPosInSet)
{
if(! dbconOpened)
Sqlite.Open();
@@ -252,26 +261,46 @@ class SqliteEncoder : Sqlite
selectStr += andString + Constants.EncoderTable + ".eccon = \"" +
EncoderSQL.Eccons.ecS.ToString() + "\"";
}
+ string fromString = " FROM " + Constants.EncoderTable + ", " +
Constants.EncoderExerciseTable;
+ if(orderRepsByPosInSet)
+ fromString += ", " + Constants.EncoderSignalCurveTable;
+
//ensure andString is defined if selectStr is != "" (bug on 2.1.2 release)
if(selectStr != "")
andString = " AND ";
string onlyActiveString = "";
if(onlyActive)
+ {
onlyActiveString = andString + Constants.EncoderTable + ".status = \"active\" ";
+ andString = " AND ";
+ }
+
+ string orderRepsByPosInSetAndStr = "";
+ if(orderRepsByPosInSet)
+ {
+ orderRepsByPosInSetAndStr = andString + Constants.EncoderTable + ".uniqueID = " +
+ Constants.EncoderSignalCurveTable + ".curveID ";
+ //andString = " AND ";
+ }
+
+ string orderRepsByPosInSetOrderStr = "";
+ if(orderRepsByPosInSet)
+ orderRepsByPosInSetOrderStr = Constants.EncoderSignalCurveTable + ".mscentral, ";
string orderIDstr = "";
if(! orderIDascendent)
orderIDstr = " DESC";
dbcmd.CommandText = "SELECT " +
- Constants.EncoderTable + ".*, " + Constants.EncoderExerciseTable + ".name FROM " +
- Constants.EncoderTable + ", " + Constants.EncoderExerciseTable +
+ Constants.EncoderTable + ".*, " + Constants.EncoderExerciseTable + ".name " +
+ fromString +
" WHERE " + selectStr +
andString + Constants.EncoderTable + ".exerciseID = " +
Constants.EncoderExerciseTable + ".uniqueID " +
- onlyActiveString +
+ onlyActiveString + orderRepsByPosInSetAndStr +
" ORDER BY substr(filename,-23,19), " + //'filename,-23,19' has the date of capture
signal
+ orderRepsByPosInSetOrderStr +
"uniqueID " + orderIDstr;
LogB.SQL(dbcmd.CommandText.ToString());
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 90c38486a..01c207cd1 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -1653,9 +1653,9 @@ class Sqlite
SqliteEncoder.createTableEncoderSignalCurve();
ArrayList signals = SqliteEncoder.Select(true, -1, -1, -1,
Constants.EncoderGI.ALL,
- -1, "signal", EncoderSQL.Eccons.ALL, "", false, false);
+ -1, "signal", EncoderSQL.Eccons.ALL, "", false, false,
false); //last false is because EncoderSignalCurve is already not created
ArrayList curves = SqliteEncoder.Select(true, -1, -1, -1,
Constants.EncoderGI.ALL,
- -1, "curve", EncoderSQL.Eccons.ALL, "", false, false);
+ -1, "curve", EncoderSQL.Eccons.ALL, "", false, false, false);
//last false is because EncoderSignalCurve is already not created
int signalID;
conversionRateTotal = signals.Count;
conversionRate = 1;
diff --git a/src/sqlite/personSession.cs b/src/sqlite/personSession.cs
index 209786e57..03ccdf530 100644
--- a/src/sqlite/personSession.cs
+++ b/src/sqlite/personSession.cs
@@ -485,7 +485,7 @@ class SqlitePersonSession : Sqlite
ArrayList encoderArray = SqliteEncoder.Select(
true, -1, Convert.ToInt32(personID), Convert.ToInt32(sessionID),
Constants.EncoderGI.ALL,
-1, "signal", EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, false);
foreach(EncoderSQL eSQL in encoderArray)
{
@@ -502,7 +502,7 @@ class SqlitePersonSession : Sqlite
encoderArray = SqliteEncoder.Select(
true, -1, Convert.ToInt32(personID), Convert.ToInt32(sessionID),
Constants.EncoderGI.ALL,
-1, "curve", EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, true);
foreach(EncoderSQL eSQL in encoderArray) {
Util.FileDelete(eSQL.GetFullURL(false)); //don't convertPathToR
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index 3971898a8..ecd3408b2 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -1052,7 +1052,7 @@ class SqliteSession : Sqlite
ArrayList encoderArray = SqliteEncoder.Select(
true, -1, -1, Convert.ToInt32(sessionID), Constants.EncoderGI.ALL,
-1, "signal", EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, false);
foreach(EncoderSQL eSQL in encoderArray) {
Util.FileDelete(eSQL.GetFullURL(false)); //signal, don't convertPathToR
@@ -1065,7 +1065,7 @@ class SqliteSession : Sqlite
encoderArray = SqliteEncoder.Select(
true, -1, -1, Convert.ToInt32(sessionID), Constants.EncoderGI.ALL,
-1, "curve", EncoderSQL.Eccons.ALL, "",
- false, true);
+ false, true, true);
foreach(EncoderSQL eSQL in encoderArray) {
Util.FileDelete(eSQL.GetFullURL(false)); //don't convertPathToR
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]