summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-11-26 16:24:19 +0100
committeremkael <emkael@tlen.pl>2016-11-26 16:24:19 +0100
commit665e91d1a86047d726aebc7cf14c2441a36b484e (patch)
tree0107c8196479b915384f4adf1d71e23afc1c550b
parent425192e081de10a7efaee8d508f7dd336d97987a (diff)
* refactoring lowBoard/highBoard methods, also allowing to specify section(s)
-rw-r--r--Aktywator/Bws.cs27
1 files changed, 20 insertions, 7 deletions
diff --git a/Aktywator/Bws.cs b/Aktywator/Bws.cs
index 4822f43..ba11b72 100644
--- a/Aktywator/Bws.cs
+++ b/Aktywator/Bws.cs
@@ -404,20 +404,33 @@ namespace Aktywator
}
}
- public int lowBoard()
+ private int getBoard(string function, string sector)
{
- string s = sql.selectOne("SELECT min(lowBoard) FROM RoundData WHERE lowBoard > 0");
+ sector = sector.Trim();
+ StringBuilder query = new StringBuilder();
+ query.Append("SELECT ");
+ query.Append(function);
+ query.Append(" FROM RoundData WHERE lowBoard > 0");
+ if (sector.Length > 0)
+ {
+ query.Append(" AND `Section` IN(");
+ query.Append(sector);
+ query.Append(")");
+ }
+ string s = sql.selectOne(query.ToString());
int i;
if (int.TryParse(s, out i)) return i;
else return 0;
}
- public int highBoard()
+ public int lowBoard(string sector = "")
{
- string s = sql.selectOne("SELECT max(highBoard) FROM RoundData WHERE highBoard > 0");
- int i;
- if (int.TryParse(s, out i)) return i;
- else return 0;
+ return this.getBoard("MIN(lowBoard)", sector);
+ }
+
+ public int highBoard(string sector = "")
+ {
+ return this.getBoard("MAX(highBoard)", sector);
}
public int highSection()