Axel Bärbar il y a 5 ans
Parent
commit
3f9fd90bbf

+ 20 - 12
ATG/src/controllers/TestingTabController.java

@@ -58,11 +58,10 @@ public class TestingTabController implements Initializable {
 
 	@FXML TextField topCountTextField;
 
-	@FXML TextField horseDriverSameOrderValue;
-	@FXML TextField horseDriverDistanceSameOrderValue;
-	@FXML TextField AllFourBasicSameOrderValue;
-	@FXML TextField AllSameOrderValue;
-
+	@FXML Label horseDriverSameOrderValue;
+	@FXML Label horseDriverDistanceSameOrderValue;
+	@FXML Label AllFourBasicSameOrderValue;
+	@FXML Label AllSameOrderValue;
 
 	@FXML TextField combineHorseWeight;
 	@FXML TextField combineDriverWeight;
@@ -72,7 +71,7 @@ public class TestingTabController implements Initializable {
 	private CSVParser parser;
 	ArrayList<TestDatabaseRow> testData = Lists.newArrayList();
 
-	ArrayList<TestDataRow> threeMonthsData = Lists.newArrayList();
+	ArrayList<TestDataRow> dbDumpTestData = Lists.newArrayList();
 
 	final HashMap<ArrayList<String>, List<SimpleEntry<Integer, Float>>> autostartWinPercentages = Maps.newHashMap();
 	final HashMap<ArrayList<String>, List<SimpleEntry<Integer, Float>>> voltstartWinPercentages = Maps.newHashMap();
@@ -147,14 +146,14 @@ public class TestingTabController implements Initializable {
 	private void ReadTestData() {
 		final Character delimiter = ',';
 		BufferedReader br;
-		threeMonthsData = Lists.newArrayList();
+		dbDumpTestData = Lists.newArrayList();
 		try {
 			br = new BufferedReader(new FileReader(testDataSetFile));
 			parser = CSVFormat.DEFAULT.withDelimiter(delimiter).withHeader().parse(br);
 
 			for (final CSVRecord record : parser) {
 				final TestDataRow row = new TestDataRow(record.toMap());
-				threeMonthsData.add(row);
+				dbDumpTestData.add(row);
 			}
 		} catch (final IOException e) {
 			e.printStackTrace();
@@ -223,7 +222,7 @@ public class TestingTabController implements Initializable {
 	public void getPercentagesOrderedBy(int topCount) {
 		// sort by RaceDate, TrackId, RaceNumber
 
-		Collections.sort(threeMonthsData, new TestDataRow.RaceDateSorter()
+		Collections.sort(dbDumpTestData, new TestDataRow.RaceDateSorter()
 				.thenComparing(new TestDataRow.TrackIdSorter())
 				.thenComparing(new TestDataRow.RaceNumberSorter()));
 
@@ -234,9 +233,15 @@ public class TestingTabController implements Initializable {
 		int correctCustom = 0;
 		int correctCombined = 0;
 		int racesCount = 0;
-		for (int i = 0; i < threeMonthsData.size(); i++) {
-			final TestDataRow firstRow = threeMonthsData.get(i);
-			final List<TestDataRow> currentRaces = threeMonthsData.stream().filter(d -> firstRow.getRaceDate().equals(d.getRaceDate()) &&
+		
+		int correctSameHorseDriver = 0;
+		int correctSameHorseDriverByDistance = 0;
+		int correctSameAllFour = 0;
+		int correctSameAll = 0;
+		
+		for (int i = 0; i < dbDumpTestData.size(); i++) {
+			final TestDataRow firstRow = dbDumpTestData.get(i);
+			final List<TestDataRow> currentRaces = dbDumpTestData.stream().filter(d -> firstRow.getRaceDate().equals(d.getRaceDate()) &&
 					firstRow.getTrackId() == d.getTrackId() &&
 					firstRow.getRaceNumber() == d.getRaceNumber()).collect(Collectors.toList());
 
@@ -277,6 +282,8 @@ public class TestingTabController implements Initializable {
 			currentRaces.forEach(cr -> cr.setLaneWinDivisor(Float.valueOf(divisorValueCustom.getText())));
 			correctCustom = checkIfCorrect(topCount, correctCustom, currentRaces, new customSorter());
 
+			
+			
 			final float horseWeight = Float.valueOf(combineHorseWeight.getText());
 			final float driverWeight = Float.valueOf(combineDriverWeight.getText());
 			currentRaces.forEach(cr -> cr.setLaneWinDivisor(Float.valueOf(divisorValueCombined.getText())));
@@ -324,6 +331,7 @@ public class TestingTabController implements Initializable {
 		}
 		//		updateTextColor(correctHorse, racesCount, horseAvgTimePercentText);
 
+		
 
 		horseAvgTimePercentValue.setText(String.valueOf(correctHorse/(racesCount * 1f) * 100) + "%");
 		horseAvgTimeByDistancePercentValue.setText(String.valueOf(correctHorseByDistance/(racesCount * 1f) * 100) + "%");

+ 1 - 1
ATG/src/fxml/TestingTab.fxml

@@ -130,7 +130,7 @@
                   <Label alignment="CENTER" style="-fx-text-fill: BLACK;" text="Horse- Driver- distance Same order" GridPane.rowIndex="7" />
                   <Label alignment="CENTER" style="-fx-text-fill: BLACK;" text="All four basic the same" GridPane.rowIndex="8" />
                   <Label fx:id="horseDriverSameOrderValue" style="-fx-text-fill: BLACK;" text="0%" GridPane.columnIndex="1" GridPane.rowIndex="6" />
-                  <Label fx:id="horseDriverDistanceSameOrderValue" prefWidth="17.0" style="-fx-text-fill: BLACK;" text="0%" GridPane.columnIndex="1" GridPane.rowIndex="7" />
+                  <Label fx:id="horseDriverDistanceSameOrderValue" style="-fx-text-fill: BLACK;" text="0%" GridPane.columnIndex="1" GridPane.rowIndex="7" />
                   <Label fx:id="AllFourBasicSameOrderValue" style="-fx-text-fill: BLACK;" text="0%" GridPane.columnIndex="1" GridPane.rowIndex="8" />
                   <Label fx:id="AllSameOrderValue" style="-fx-text-fill: BLACK;" text="0%" GridPane.columnIndex="1" GridPane.rowIndex="9" />
                   <Label alignment="CENTER" style="-fx-text-fill: BLACK;" text="All the same" GridPane.rowIndex="9" />

+ 8 - 4
ATG/src/test/TestDataRow.java

@@ -33,24 +33,28 @@ public class TestDataRow {
 		timeModifier = map.get("TimeModifier");
 		trackId = Integer.valueOf(map.get("TrackId"));
 
-		if (map.get("HorseAvgTime").equals("NA")) {
+		if (map.get("HorseAvgTime").equals("NA") || 
+				map.get("HorseAvgTime").toLowerCase().equals("null")) {
 			horseAvgTime = -1f;
 		} else {
 			horseAvgTime = Float.valueOf(map.get("HorseAvgTime"));
 		}
-		if (map.get("horseAvgByDistance").equals("NA")) {
+		if (map.get("horseAvgByDistance").equals("NA") || 
+				map.get("horseAvgByDistance").toLowerCase().equals("null")) {
 			horseAvgTimeByDistance = -1f;
 		} else {
 			horseAvgTimeByDistance = Float.valueOf(map.get("horseAvgByDistance"));
 		}
 
-		if (map.get("driverAvgTime").equals("NA")) {
+		if (map.get("driverAvgTime").equals("NA") || 
+				map.get("driverAvgTime").toLowerCase().equals("null")) {
 			driverAvgTime = -1f;
 		} else {
 			driverAvgTime = Float.valueOf(map.get("driverAvgTime"));
 		}
 
-		if (map.get("driverAvgByDistance").equals("NA")) {
+		if (map.get("driverAvgByDistance").equals("NA") || 
+				map.get("driverAvgByDistance").toLowerCase().equals("null")) {
 			driverAvgTimeByDistance = -1f;
 		} else {
 			driverAvgTimeByDistance = Float.valueOf(map.get("driverAvgByDistance"));