Skip to content

Commit

Permalink
Merge pull request #9 from XIVStats/determine-activity
Browse files Browse the repository at this point in the history
Merged change to determine player activity based on profile image creation date, rather than existing system of looking at story completion minion.
  • Loading branch information
Pricetx authored Mar 8, 2017
2 parents 2e9f6c8 + 724a9d7 commit 95d85be
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 31 deletions.
44 changes: 24 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.*
Expand Down
27 changes: 26 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.ffxivcensus.gatherer</groupId>
<artifactId>XIVStats-Gatherer-Java</artifactId>
<version>v1.1.0</version>
<version>v1.2.0</version>
<name>XIVStats Lodestone Gatherer</name>
<url>https://github.com/xivstats</url>

Expand Down Expand Up @@ -155,6 +155,31 @@
<artifactId>commons-cli</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3.6</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
</dependencies>

</project>
12 changes: 11 additions & 1 deletion src/main/java/com/ffxivcensus/gatherer/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down
55 changes: 54 additions & 1 deletion src/main/java/com/ffxivcensus/gatherer/GathererController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -228,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;
}

/**
Expand Down Expand Up @@ -344,6 +354,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());
Expand Down Expand Up @@ -509,6 +527,25 @@ protected String writeToDB(Player player) {
sbValues.append("\"" + player.getMountsString() + "\"");
}


if(this.storeActiveDate) {
sbFields.append(",");
sbValues.append(",");
sbFields.append("date_active");
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(",");
sbValues.append(",");
sbFields.append("is_active");
sbValues.append(player.getBitIsActive());
}

sbFields.append(")");
sbValues.append(");");

Expand Down Expand Up @@ -734,7 +771,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;
Expand Down Expand Up @@ -787,4 +824,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;
}
}
Loading

0 comments on commit 95d85be

Please sign in to comment.