From 10e6348dcf33c538f0d4f3e6c0339b69b9a26f9e Mon Sep 17 00:00:00 2001 From: Julian Arndt Date: Tue, 10 Nov 2020 11:26:39 +0100 Subject: [PATCH] Improve match list in forum to match tlw league config --- .../tippligaforum/MatchesListCreator.java | 20 +++++++++++++----- .../tippligaforum/MatchesListCreatorTest.java | 2 +- .../MatchesListForumUpdaterTest.java | 2 +- tokens/StoredCredential | Bin 1089 -> 1089 bytes 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/jeyp91/tippligaforum/MatchesListCreator.java b/src/main/java/de/jeyp91/tippligaforum/MatchesListCreator.java index dcdb47d..758e29b 100644 --- a/src/main/java/de/jeyp91/tippligaforum/MatchesListCreator.java +++ b/src/main/java/de/jeyp91/tippligaforum/MatchesListCreator.java @@ -3,12 +3,13 @@ package de.jeyp91.tippligaforum; import com.google.gson.*; import de.jeyp91.S3Provider; import de.jeyp91.apifootball.APIFootballMatch; +import netscape.javascript.JSObject; import org.json.simple.JSONArray; import org.json.simple.JSONObject; public class MatchesListCreator { - private final JSONObject matches = new JSONObject(); + private final JSONObject mainObject = new JSONObject(); private final String country; private final String leagueName; @@ -17,12 +18,21 @@ public class MatchesListCreator { JSONObject leagueConfig = prov.getFixturesJSONFromS3(league); JSONObject api = (JSONObject) leagueConfig.get("api"); JSONArray matchesAPIFootball = (JSONArray) api.get("fixtures"); + JSONObject firstMatchAPIFootball = (JSONObject) matchesAPIFootball.get(0); JSONObject leagueObject = (JSONObject) firstMatchAPIFootball.get("league"); this.country = leagueObject.get("country").toString(); this.leagueName = leagueObject.get("name").toString(); - JSONArray matches = populateMatches(matchesAPIFootball); - this.matches.put("matches", matches); + + JSONArray matchesConfig = populateMatches(matchesAPIFootball); + + JSONObject matchdayConfigObject = new JSONObject(); + matchdayConfigObject.put("matchesConfig", matchesConfig); + + JSONArray matchdayConfig = new JSONArray(); + matchdayConfig.add(matchdayConfigObject); + + this.mainObject.put("matchdayConfig", matchdayConfig); } private JSONArray populateMatches(JSONArray matchesAPIFootball) { @@ -55,11 +65,11 @@ public class MatchesListCreator { } public JSONObject getMatches() { - return this.matches; + return this.mainObject; } public String getMatchesBeautiful() { - JsonElement jelement = JsonParser.parseString(this.matches.toString()); + JsonElement jelement = JsonParser.parseString(this.mainObject.toString()); Gson gson = new GsonBuilder().setPrettyPrinting().create(); return gson.toJson(jelement); } diff --git a/src/test/java/de/jeyp91/tippligaforum/MatchesListCreatorTest.java b/src/test/java/de/jeyp91/tippligaforum/MatchesListCreatorTest.java index 50e1358..f985a8b 100644 --- a/src/test/java/de/jeyp91/tippligaforum/MatchesListCreatorTest.java +++ b/src/test/java/de/jeyp91/tippligaforum/MatchesListCreatorTest.java @@ -16,7 +16,7 @@ public class MatchesListCreatorTest { public void getMatchesTest2743() { MatchesListCreator creator = new MatchesListCreator(2743); String matches = creator.getMatchesBeautiful(); -// System.out.println(matches); + System.out.println(matches); } @Test diff --git a/src/test/java/de/jeyp91/tippligaforum/MatchesListForumUpdaterTest.java b/src/test/java/de/jeyp91/tippligaforum/MatchesListForumUpdaterTest.java index e2f9005..fbc85d7 100644 --- a/src/test/java/de/jeyp91/tippligaforum/MatchesListForumUpdaterTest.java +++ b/src/test/java/de/jeyp91/tippligaforum/MatchesListForumUpdaterTest.java @@ -16,6 +16,6 @@ public class MatchesListForumUpdaterTest { @Test public void updateLeagueTest() { MatchesListForumUpdater updater = new MatchesListForumUpdater(); -// updater.updateLeague(2743); + updater.updateLeague(2743); } } diff --git a/tokens/StoredCredential b/tokens/StoredCredential index 541b3c4893110defb95f0bba3adb9e973482a368..7b1c4d4eddc1acbaa0e95ff8f4e2af03e565513a 100644 GIT binary patch delta 190 zcmV~$T@ryn007`&Jh+O7W+XJdq0%3AYe%s!O}qWj4@!w%+`&m0CvXK3+J; zP3tbo0m8$TUDu4l9Z405{+c>|1v3)IMkbqER)zmSJ)QWDkmjGzQkgL(e*m7Ft>> o1<4FPkm-Dkn1)-GUlmr#&A%RK>M59+|je{_c3v^m<7)N%NU^gJ9bF-T5fz35FY?qqc nfF^*NJ;1!Oe+YQ`^uOCT5q^_D6`4TJ