From a821b46c45c05d22ca3366f61353b00d80b79401 Mon Sep 17 00:00:00 2001 From: Peter Reid Date: Wed, 8 Mar 2017 17:02:19 +0000 Subject: [PATCH 1/8] [[XIVStats#1] Implemented better means of determing player activity. I've implemented a better means of determining player activity by parsing the 'last-modified' header of the character's full body image. --- pom.xml | 25 ++++++++ .../java/com/ffxivcensus/gatherer/Player.java | 64 +++++++++++++++++-- .../com/ffxivcensus/gatherer/PlayerTest.java | 4 ++ 3 files changed, 88 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 57fb5a3..796b82c 100644 --- a/pom.xml +++ b/pom.xml @@ -155,6 +155,31 @@ commons-cli 1.3.1 + + org.apache.httpcomponents + httpclient + 4.3.6 + + + org.apache.httpcomponents + httpasyncclient + 4.0.2 + + + org.apache.httpcomponents + httpmime + 4.3.6 + + + org.json + json + 20140107 + + + com.mashape.unirest + unirest-java + 1.4.9 + diff --git a/src/main/java/com/ffxivcensus/gatherer/Player.java b/src/main/java/com/ffxivcensus/gatherer/Player.java index a27bf39..15d0229 100644 --- a/src/main/java/com/ffxivcensus/gatherer/Player.java +++ b/src/main/java/com/ffxivcensus/gatherer/Player.java @@ -1,15 +1,20 @@ package com.ffxivcensus.gatherer; +import com.mashape.unirest.http.HttpResponse; +import com.mashape.unirest.http.JsonNode; +import com.mashape.unirest.http.Unirest; +import com.mashape.unirest.http.exceptions.UnirestException; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import java.io.IOException; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Statement; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.regex.Pattern; /** @@ -86,6 +91,7 @@ public class Player { private boolean isLegacyPlayer; private ArrayList minions; private ArrayList mounts; + private Date imgLastModified; /** * Constructor for player object. @@ -154,6 +160,7 @@ public Player(int id) { setHasCompletedHW(false); setHasCompleted3pt1(false); setHasCompleted3pt3(false); + setImgLastModified(new Date()); } /** @@ -1654,8 +1661,16 @@ public int getBitHasCompleted3pt3() { */ public void setHasCompleted3pt3(boolean hasCompleted3pt3) { this.hasCompleted3pt3 = hasCompleted3pt3; - } - + } + + /** + * Set the date on which the player's avatar was last modified + * @param imgLastModified the date on which the player's avatar was last modified + */ + public void setImgLastModified(Date imgLastModified) { + this.imgLastModified = imgLastModified; + } + /** * Get whether the user played 1.0. * @@ -1830,6 +1845,7 @@ public static Player getPlayer(int playerID) throws Exception { player.setGender(getGenderFromPage(doc)); player.setGrandCompany(getGrandCompanyFromPage(doc)); player.setFreeCompany(getFreeCompanyFromPage(doc)); + player.setImgLastModified(getDateLastUpdatedFromPage(doc)); player.setLevels(getLevelsFromPage(doc)); player.setMounts(getMountsFromPage(doc)); player.setMinions(getMinionsFromPage(doc)); @@ -2077,4 +2093,42 @@ private static ArrayList getMountsFromPage(Document doc) { return mounts; } + /** + * Gets the last-modified date of the Character full body image. + * @param doc the lodestone profile page to parse + * @return the date on which the full body image was last modified. + */ + private static Date getDateLastUpdatedFromPage(Document doc) throws Exception { + Date dateLastModified = new Date(); + //Get character image URL. + String imgUrl = doc.getElementsByClass("bg_chara_264").get(0).getElementsByTag("img").get(0).attr("src"); + String strLastModifiedDate = ""; + + try { + HttpResponse jsonResponse = Unirest.head(imgUrl).asJson(); + + strLastModifiedDate = jsonResponse.getHeaders().get("Last-Modified").toString(); + } catch (UnirestException e) { + e.printStackTrace(); + } + + strLastModifiedDate = strLastModifiedDate.replace("[", ""); + strLastModifiedDate = strLastModifiedDate.replace("]", ""); + DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz"); + + try { + dateLastModified = dateFormat.parse(strLastModifiedDate); + } catch (ParseException e) { + throw new Exception("Could not correctly parse date 'Last-Modified' header from full body image"); + } + return dateLastModified; + } + + /** + * Get the date on which the Character's full body image was last modified + * @return the date on which the Character's full body image was last modified + */ + public Date getImgLastModified() { + return imgLastModified; + } } diff --git a/src/test/java/com/ffxivcensus/gatherer/PlayerTest.java b/src/test/java/com/ffxivcensus/gatherer/PlayerTest.java index e2fd961..3035906 100644 --- a/src/test/java/com/ffxivcensus/gatherer/PlayerTest.java +++ b/src/test/java/com/ffxivcensus/gatherer/PlayerTest.java @@ -2,6 +2,8 @@ import com.ffxivcensus.gatherer.Player; +import java.util.Date; + import static org.junit.Assert.*; /** @@ -221,6 +223,8 @@ public void testUnplayedPlayer() throws Exception { assertEquals(player.getBitHasCompletedHW(), 0); assertEquals(player.getBitHasCompleted3pt1(), 0); assertEquals(player.getBitHasARRCollectors(), 0); + //Tricky to test this - testing here that it was at the very least set to some value other than what it is set to a value other than that which it is initialized + assertTrue(player.getImgLastModified() != new Date()); //Test get minions method assertTrue(player.getMinions().size() == 0); From 92c3b32e0c1abcbe46c0c04f0d91a18105b44ce3 Mon Sep 17 00:00:00 2001 From: Peter Reid Date: Wed, 8 Mar 2017 17:34:51 +0000 Subject: [PATCH 2/8] [XIVStats#1] Updated variable name --- .../java/com/ffxivcensus/gatherer/Player.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/ffxivcensus/gatherer/Player.java b/src/main/java/com/ffxivcensus/gatherer/Player.java index 15d0229..894b0ce 100644 --- a/src/main/java/com/ffxivcensus/gatherer/Player.java +++ b/src/main/java/com/ffxivcensus/gatherer/Player.java @@ -91,7 +91,7 @@ public class Player { private boolean isLegacyPlayer; private ArrayList minions; private ArrayList mounts; - private Date imgLastModified; + private Date dateImgLastModified; /** * Constructor for player object. @@ -160,7 +160,7 @@ public Player(int id) { setHasCompletedHW(false); setHasCompleted3pt1(false); setHasCompleted3pt3(false); - setImgLastModified(new Date()); + setDateImgLastModified(new Date()); } /** @@ -1665,10 +1665,10 @@ public void setHasCompleted3pt3(boolean hasCompleted3pt3) { /** * Set the date on which the player's avatar was last modified - * @param imgLastModified the date on which the player's avatar was last modified + * @param dateImgLastModified the date on which the player's avatar was last modified */ - public void setImgLastModified(Date imgLastModified) { - this.imgLastModified = imgLastModified; + public void setDateImgLastModified(Date dateImgLastModified) { + this.dateImgLastModified = dateImgLastModified; } /** @@ -1845,7 +1845,7 @@ public static Player getPlayer(int playerID) throws Exception { player.setGender(getGenderFromPage(doc)); player.setGrandCompany(getGrandCompanyFromPage(doc)); player.setFreeCompany(getFreeCompanyFromPage(doc)); - player.setImgLastModified(getDateLastUpdatedFromPage(doc)); + player.setDateImgLastModified(getDateLastUpdatedFromPage(doc)); player.setLevels(getLevelsFromPage(doc)); player.setMounts(getMountsFromPage(doc)); player.setMinions(getMinionsFromPage(doc)); @@ -2128,7 +2128,7 @@ private static Date getDateLastUpdatedFromPage(Document doc) throws Exception { * Get the date on which the Character's full body image was last modified * @return the date on which the Character's full body image was last modified */ - public Date getImgLastModified() { - return imgLastModified; + public Date getDateImgLastModified() { + return dateImgLastModified; } } From e56e485d0934456005f5451503cea9bf5adb09fe Mon Sep 17 00:00:00 2001 From: Peter Reid Date: Wed, 8 Mar 2017 17:53:14 +0000 Subject: [PATCH 3/8] [XIVStats#1] Added code to determine whether Character 'has been active in last 30 days' --- .../java/com/ffxivcensus/gatherer/Player.java | 52 +++++++++++++++++++ .../com/ffxivcensus/gatherer/PlayerTest.java | 6 ++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ffxivcensus/gatherer/Player.java b/src/main/java/com/ffxivcensus/gatherer/Player.java index 894b0ce..373bf06 100644 --- a/src/main/java/com/ffxivcensus/gatherer/Player.java +++ b/src/main/java/com/ffxivcensus/gatherer/Player.java @@ -14,6 +14,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; import java.util.regex.Pattern; @@ -27,6 +28,20 @@ */ public class Player { + /** + * Number of days inactivity before character is considered inactive + */ + private final static int ACTIVITY_RANGE_DAYS = 30; + + + private static final long ONE_MINUTE_IN_MILLIS=60000; + private static final long ONE_DAY_IN_MILLIS=86400000; + + /** + * Ignore dates from inside EXCLUDE_RANGE in minutes + */ + private static final long EXCLUDE_RANGE= 5; + private int id; private String realm; private String playerName; @@ -92,6 +107,7 @@ public class Player { private ArrayList minions; private ArrayList mounts; private Date dateImgLastModified; + private boolean isActive; /** * Constructor for player object. @@ -161,6 +177,7 @@ public Player(int id) { setHasCompleted3pt1(false); setHasCompleted3pt3(false); setDateImgLastModified(new Date()); + setActive(false); } /** @@ -1881,12 +1898,31 @@ public static Player getPlayer(int playerID) throws Exception { player.setHasSylph(player.doesPlayerHaveMount("Laurel Goobbue")); player.setHasCompletedHW(player.doesPlayerHaveMount("Midgardsormr")); player.setIsLegacyPlayer(player.doesPlayerHaveMount("Legacy Chocobo")); + player.setActive(player.isPlayerActiveInDateRange()); } catch (IOException ioEx) { throw new Exception("Character " + playerID + " does not exist."); } return player; } + /** + * Determine whether a player is active based upon the last modified date of their full body image + * @return whether player has been active inside the activity window + */ + private boolean isPlayerActiveInDateRange() { + + Calendar date = Calendar.getInstance(); + long t= date.getTimeInMillis(); + Date nowMinusExcludeRange =new Date(t - (EXCLUDE_RANGE * ONE_MINUTE_IN_MILLIS)); + + Date nowMinusIncludeRange = new Date(t - (ACTIVITY_RANGE_DAYS * ONE_DAY_IN_MILLIS)); + if(this.dateImgLastModified.after(nowMinusExcludeRange)) { //If the date modified is inside the exclude range + //Reset the last modified date to epoch because we aren't considering it valid + this.dateImgLastModified = new Date(0); + return false; + } else return this.dateImgLastModified.after(nowMinusIncludeRange); //If the date occurs between the include range and now, then return true. Else false + } + /** * Given a lodestone profile page, return the name of the character. * @@ -2131,4 +2167,20 @@ private static Date getDateLastUpdatedFromPage(Document doc) throws Exception { public Date getDateImgLastModified() { return dateImgLastModified; } + + /** + * Get whether a Player is active + * @return whether Player is active + */ + public boolean isActive() { + return isActive; + } + + /** + * Set whether Player is active + * @param active whether player is considered active + */ + public void setActive(boolean active) { + isActive = active; + } } diff --git a/src/test/java/com/ffxivcensus/gatherer/PlayerTest.java b/src/test/java/com/ffxivcensus/gatherer/PlayerTest.java index 3035906..b197c78 100644 --- a/src/test/java/com/ffxivcensus/gatherer/PlayerTest.java +++ b/src/test/java/com/ffxivcensus/gatherer/PlayerTest.java @@ -156,6 +156,9 @@ public void testGetPlayer() throws Exception { assertTrue(playerOne.getMountsString().contains("Cavalry Drake,Cavalry Elbst")); //Test for data from very end assertTrue(playerOne.getMountsString().contains("Midgardsormr")); + + //Is active + assertTrue(playerOne.isActive()); } /** @@ -224,7 +227,8 @@ public void testUnplayedPlayer() throws Exception { assertEquals(player.getBitHasCompleted3pt1(), 0); assertEquals(player.getBitHasARRCollectors(), 0); //Tricky to test this - testing here that it was at the very least set to some value other than what it is set to a value other than that which it is initialized - assertTrue(player.getImgLastModified() != new Date()); + assertTrue(player.getDateImgLastModified() != new Date()); + assertFalse(player.isActive()); //Test get minions method assertTrue(player.getMinions().size() == 0); From ab180f3779b371afd88c33a35f4b4e6454f0a1c7 Mon Sep 17 00:00:00 2001 From: Peter Reid Date: Wed, 8 Mar 2017 18:20:17 +0000 Subject: [PATCH 4/8] [XIVStats#1] Added flags for storing activity data --- README.md | 44 ++++++++++-------- .../com/ffxivcensus/gatherer/Console.java | 12 ++++- .../gatherer/GathererController.java | 46 +++++++++++++++++++ .../java/com/ffxivcensus/gatherer/Player.java | 9 ++++ 4 files changed, 90 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 9444c18..c33c51c 100644 --- a/README.md +++ b/README.md @@ -66,26 +66,28 @@ Follow these steps to setup XIVStats-Gatherer-Java: ``` The application can be run with the following command line options/args: - | Short option | Long option | Argument type | Description | - |:------------:|:---------------------:|:--------------:|:---------------------------------------------------------:| - |-b |--do-not-store-progress| none | do not store boolean data indicating player progress | - |-d | --database | String | database name | - |-f | --finish | integer | the character id to conclude character run at (inclusive) | - |-F | --print-failures | none | print records that don't exist | - |-h | --help | none | display help message | - |-m | --store-mounts | none | store mount data set for each player into the database | - |-P | --store-minions | none | store minion data set for each player into the database | - |-p | --password | String | database user password | - |-q | --quiet | none | run program in quiet mode - no console output | - |-s | --start | integer | the character id to start from (inclusive) | - |-S | --split-table | none | split table into several small tables | - |-t | --threads | integer | number of gatherer thrads to running | - |-T | --table | String | the table to write records to | - |-u | --user | String | database user | - |-U | --url | String | the database URL of the database server to connect to | - |-v | --verbose | none | run program in verbose mode - full console output | - |-x | --suffix | String | suffix to append to all tables generated | - + | Short option | Long option | Argument type | Description | + |:------------:|:---------------------:|:--------------:|:--------------------------------------------------------------------:| + |-a |--do-not-store-activity| none | do not store boolean data indicating player activity in last 30 days | + |-b |--do-not-store-progress| none | do not store boolean data indicating player progress | + |-d | --database | String | database name | + |-D | --do-not-store-date | none | do not store date of last player activity | + |-f | --finish | integer | the character id to conclude character run at (inclusive) | + |-F | --print-failures | none | print records that don't exist | + |-h | --help | none | display help message | + |-m | --store-mounts | none | store mount data set for each player into the database | + |-P | --store-minions | none | store minion data set for each player into the database | + |-p | --password | String | database user password | + |-q | --quiet | none | run program in quiet mode - no console output | + |-s | --start | integer | the character id to start from (inclusive) | + |-S | --split-table | none | split table into several small tables | + |-t | --threads | integer | number of gatherer thrads to running | + |-T | --table | String | the table to write records to | + |-u | --user | String | database user | + |-U | --url | String | the database URL of the database server to connect to | + |-v | --verbose | none | run program in verbose mode - full console output | + |-x | --suffix | String | suffix to append to all tables generated | + Note: On Linux/Unix it is advised to run the program in Tmux/Screen or similar. @@ -175,6 +177,8 @@ The database table ```tblplayers``` has the following structure: |legacy_player |bit |Mount - Legacy Chocobo | |*mounts* |*text* |*N/A* | |*minions* |*text* |*N/A* | +|date_active |date |N/A | +|is_active |bit |N/A | *Italicised fields are only completed jf specified with a command line flag.* diff --git a/src/main/java/com/ffxivcensus/gatherer/Console.java b/src/main/java/com/ffxivcensus/gatherer/Console.java index 3092f15..88864c9 100644 --- a/src/main/java/com/ffxivcensus/gatherer/Console.java +++ b/src/main/java/com/ffxivcensus/gatherer/Console.java @@ -26,7 +26,7 @@ public static GathererController run(String [] args){ Options options = setupOptions(); //Declare usage string - String usage = "java -jar XIVStats-Gatherer-Java.jar [-bmqvxFPS] -s startid -f finishid [-d database-name] [-u database-user] [-p database-user-password] [-U database-url] [-T table] [-t threads]"; + String usage = "java -jar XIVStats-Gatherer-Java.jar [-abmqvxDFPS] -s startid -f finishid [-d database-name] [-u database-user] [-p database-user-password] [-U database-url] [-T table] [-t threads]"; HelpFormatter formatter = new HelpFormatter(); try{ @@ -62,6 +62,12 @@ public static GathererController run(String [] args){ //Store progression gatherer.setStoreProgression(!cmd.hasOption("b")); + //Store whether player is active + gatherer.setStorePlayerActive(!cmd.hasOption("a")); + + //Store player active date + gatherer.setStoreActiveDate(!cmd.hasOption("D")); + //Database URL if(cmd.hasOption("d") && cmd.hasOption("U")){ gatherer.setDbUrl("jdbc:" + cmd.getOptionValue("U") + "/" + cmd.getOptionValue("d")); @@ -143,6 +149,8 @@ public static Options setupOptions(){ Option optVerbose = Option.builder("v").longOpt("verbose").desc("run program in verbose bug mode - full console output").build(); Option optFailPrint = Option.builder("F").longOpt("print-failures").desc("print records that don't exist").build(); Option optSuffix = Option.builder("x").longOpt("suffix").hasArg().numberOfArgs(1).argName("table-suffix").desc("suffix to append to all tables").build(); + Option optStoreActive = Option.builder("a").longOpt("do-not-store-activity").desc("do not store boolean data indicating player activity in last 30 days").build(); + Option optStoreDate = Option.builder("D").longOpt("do-not-store-date").desc("do not store Date of last player activity").build(); //Add each option to the options object options.addOption(optStart); @@ -162,6 +170,8 @@ public static Options setupOptions(){ options.addOption(optVerbose); options.addOption(optFailPrint); options.addOption(optSuffix); + options.addOption(optStoreActive); + options.addOption(optStoreDate); return options; } diff --git a/src/main/java/com/ffxivcensus/gatherer/GathererController.java b/src/main/java/com/ffxivcensus/gatherer/GathererController.java index eef3629..92a9823 100644 --- a/src/main/java/com/ffxivcensus/gatherer/GathererController.java +++ b/src/main/java/com/ffxivcensus/gatherer/GathererController.java @@ -92,6 +92,14 @@ public class GathererController { * Whether to output failed records */ private boolean printFails; + /** + * Whether to store player activity dates + */ + private boolean storeActiveDate; + /** + * Whether to store player activity bit + */ + private boolean storePlayerActive; /** * List of playable realms (used when splitting tables). @@ -344,6 +352,14 @@ private void createTable(String tableName) { if (this.storeMinions) { sbSQL.append(",minions TEXT"); } + if(this.storeActiveDate) { + sbSQL.append(","); + sbSQL.append("date_active DATE"); + } + if(this.storePlayerActive) { + sbSQL.append(","); + sbSQL.append("is_active BIT"); + } sbSQL.append(");"); st.executeUpdate(sbSQL.toString()); @@ -509,6 +525,20 @@ protected String writeToDB(Player player) { sbValues.append("\"" + player.getMountsString() + "\""); } + + if(this.storeActiveDate) { + sbFields.append(","); + sbValues.append(","); + sbFields.append("date_active"); + sbValues.append(player.getDateImgLastModified()); + } + if(this.storePlayerActive) { + sbFields.append(","); + sbValues.append(","); + sbFields.append("is_active"); + sbValues.append(player.getBitIsActive()); + } + sbFields.append(")"); sbValues.append(");"); @@ -787,4 +817,20 @@ public boolean isPrintFails() { public void setPrintFails(boolean printFails) { this.printFails = printFails; } + + /** + * Set whether to store the last active date of a character + * @param storeActiveDate whether to store the last active date of a character + */ + public void setStoreActiveDate(boolean storeActiveDate) { + this.storeActiveDate = storeActiveDate; + } + + /** + * Set whether to store a boolean value indicating player activity + * @param storePlayerActive whether to store a boolean value indicating player activity + */ + public void setStorePlayerActive(boolean storePlayerActive) { + this.storePlayerActive = storePlayerActive; + } } diff --git a/src/main/java/com/ffxivcensus/gatherer/Player.java b/src/main/java/com/ffxivcensus/gatherer/Player.java index 373bf06..f7dc912 100644 --- a/src/main/java/com/ffxivcensus/gatherer/Player.java +++ b/src/main/java/com/ffxivcensus/gatherer/Player.java @@ -2176,6 +2176,15 @@ public boolean isActive() { return isActive; } + /** + * Get whether a Player is active + * @return whether Player is active + */ + public int getBitIsActive() { + if(this.isActive) return 1; + return 0; + } + /** * Set whether Player is active * @param active whether player is considered active From cfe65c96f01f1a9dd304ca9ce19dc80616972112 Mon Sep 17 00:00:00 2001 From: Peter Reid Date: Wed, 8 Mar 2017 18:20:54 +0000 Subject: [PATCH 5/8] [XIVStats#1] Bumped version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 796b82c..6e03355 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ffxivcensus.gatherer XIVStats-Gatherer-Java - v1.1.0 + v1.2.0 XIVStats Lodestone Gatherer https://github.com/xivstats From 9d6141eabe6306b7edb58afecd96e776dada1716 Mon Sep 17 00:00:00 2001 From: Peter Reid Date: Wed, 8 Mar 2017 18:22:42 +0000 Subject: [PATCH 6/8] Fixed javadoc bug --- src/main/java/com/ffxivcensus/gatherer/GathererController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/ffxivcensus/gatherer/GathererController.java b/src/main/java/com/ffxivcensus/gatherer/GathererController.java index 92a9823..a72f14e 100644 --- a/src/main/java/com/ffxivcensus/gatherer/GathererController.java +++ b/src/main/java/com/ffxivcensus/gatherer/GathererController.java @@ -764,7 +764,7 @@ public void setVerbose(boolean verbose) { } /** * Get list of realms to create tables for - * @return + * @return array of realm names */ public static String[] getRealms() { return realms; From 2496d421fdc911fdc6effb54c82291588e0aea1a Mon Sep 17 00:00:00 2001 From: Peter Reid Date: Wed, 8 Mar 2017 18:43:59 +0000 Subject: [PATCH 7/8] Fixed bug storing date to database --- .../com/ffxivcensus/gatherer/GathererController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ffxivcensus/gatherer/GathererController.java b/src/main/java/com/ffxivcensus/gatherer/GathererController.java index a72f14e..c8c8a96 100644 --- a/src/main/java/com/ffxivcensus/gatherer/GathererController.java +++ b/src/main/java/com/ffxivcensus/gatherer/GathererController.java @@ -236,6 +236,8 @@ public GathererController(int startId, int endId, boolean quiet, boolean verbose this.tableName = "tblplayers"; this.tableSuffix = tableSuffix; this.splitTables = splitTables; + this.storeActiveDate = true; + this.storePlayerActive = true; } /** @@ -530,7 +532,12 @@ protected String writeToDB(Player player) { sbFields.append(","); sbValues.append(","); sbFields.append("date_active"); - sbValues.append(player.getDateImgLastModified()); + java.util.Date dt = new java.util.Date(); + + java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd"); + + String sqlDate = sdf.format(player.getDateImgLastModified()); + sbValues.append("\"" + sqlDate + "\""); } if(this.storePlayerActive) { sbFields.append(","); From 724a9d74b682f414310cbad03739625d529e1785 Mon Sep 17 00:00:00 2001 From: Peter Reid Date: Wed, 8 Mar 2017 18:49:49 +0000 Subject: [PATCH 8/8] Fixed failing tests --- src/test/java/com/ffxivcensus/gatherer/ConsoleTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/ffxivcensus/gatherer/ConsoleTest.java b/src/test/java/com/ffxivcensus/gatherer/ConsoleTest.java index 6a5de7c..5765c3a 100644 --- a/src/test/java/com/ffxivcensus/gatherer/ConsoleTest.java +++ b/src/test/java/com/ffxivcensus/gatherer/ConsoleTest.java @@ -168,7 +168,7 @@ public void testConsoleFullOptions() throws Exception { @Test public void TestConsoleHelpDefault() throws Exception { - String strHelp = "usage: java -jar XIVStats-Gatherer-Java.jar [-bmqvxFPS] -s startid -f"; + String strHelp = "usage: java -jar XIVStats-Gatherer-Java.jar [-abmqvxDFPS] -s startid -f"; //Test for a help dialog displayed upon failure String[] args = {""}; @@ -180,7 +180,7 @@ public void TestConsoleHelpDefault() throws Exception { @Test public void TestConsoleHelpOnFail() throws Exception { - String strHelp = "usage: java -jar XIVStats-Gatherer-Java.jar [-bmqvxFPS] -s startid -f"; + String strHelp = "usage: java -jar XIVStats-Gatherer-Java.jar [-abmqvxDFPS] -s startid -f"; //Test for a help dialog displayed upon failure String[] args = {"-s 0"}; GathererController gc = Console.run(args); @@ -192,7 +192,7 @@ public void TestConsoleHelpOnFail() throws Exception { @Test public void TestConsoleHelp() throws Exception { - String strHelp = "usage: java -jar XIVStats-Gatherer-Java.jar [-bmqvxFPS] -s startid -f"; + String strHelp = "usage: java -jar XIVStats-Gatherer-Java.jar [-abmqvxDFPS] -s startid -f"; //First test for a user requested help dialog String[] args = {"--help"};