Skip to content

Commit 95d85be

Browse files
authored
Merge pull request #9 from XIVStats/determine-activity
Merged change to determine player activity based on profile image creation date, rather than existing system of looking at story completion minion.
2 parents 2e9f6c8 + 724a9d7 commit 95d85be

File tree

7 files changed

+246
-31
lines changed

7 files changed

+246
-31
lines changed

README.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,28 @@ Follow these steps to setup XIVStats-Gatherer-Java:
6666
```
6767
The application can be run with the following command line options/args:
6868

69-
| Short option | Long option | Argument type | Description |
70-
|:------------:|:---------------------:|:--------------:|:---------------------------------------------------------:|
71-
|-b |--do-not-store-progress| none | do not store boolean data indicating player progress |
72-
|-d | --database | String | database name |
73-
|-f | --finish | integer | the character id to conclude character run at (inclusive) |
74-
|-F | --print-failures | none | print records that don't exist |
75-
|-h | --help | none | display help message |
76-
|-m | --store-mounts | none | store mount data set for each player into the database |
77-
|-P | --store-minions | none | store minion data set for each player into the database |
78-
|-p | --password | String | database user password |
79-
|-q | --quiet | none | run program in quiet mode - no console output |
80-
|-s | --start | integer | the character id to start from (inclusive) |
81-
|-S | --split-table | none | split table into several small tables |
82-
|-t | --threads | integer | number of gatherer thrads to running |
83-
|-T | --table | String | the table to write records to |
84-
|-u | --user | String | database user |
85-
|-U | --url | String | the database URL of the database server to connect to |
86-
|-v | --verbose | none | run program in verbose mode - full console output |
87-
|-x | --suffix | String | suffix to append to all tables generated |
88-
69+
| Short option | Long option | Argument type | Description |
70+
|:------------:|:---------------------:|:--------------:|:--------------------------------------------------------------------:|
71+
|-a |--do-not-store-activity| none | do not store boolean data indicating player activity in last 30 days |
72+
|-b |--do-not-store-progress| none | do not store boolean data indicating player progress |
73+
|-d | --database | String | database name |
74+
|-D | --do-not-store-date | none | do not store date of last player activity |
75+
|-f | --finish | integer | the character id to conclude character run at (inclusive) |
76+
|-F | --print-failures | none | print records that don't exist |
77+
|-h | --help | none | display help message |
78+
|-m | --store-mounts | none | store mount data set for each player into the database |
79+
|-P | --store-minions | none | store minion data set for each player into the database |
80+
|-p | --password | String | database user password |
81+
|-q | --quiet | none | run program in quiet mode - no console output |
82+
|-s | --start | integer | the character id to start from (inclusive) |
83+
|-S | --split-table | none | split table into several small tables |
84+
|-t | --threads | integer | number of gatherer thrads to running |
85+
|-T | --table | String | the table to write records to |
86+
|-u | --user | String | database user |
87+
|-U | --url | String | the database URL of the database server to connect to |
88+
|-v | --verbose | none | run program in verbose mode - full console output |
89+
|-x | --suffix | String | suffix to append to all tables generated |
90+
8991

9092
Note: On Linux/Unix it is advised to run the program in Tmux/Screen or similar.
9193

@@ -175,6 +177,8 @@ The database table ```tblplayers``` has the following structure:
175177
|legacy_player |bit |Mount - Legacy Chocobo |
176178
|*mounts* |*text* |*N/A* |
177179
|*minions* |*text* |*N/A* |
180+
|date_active |date |N/A |
181+
|is_active |bit |N/A |
178182
179183
*Italicised fields are only completed jf specified with a command line flag.*
180184

pom.xml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.ffxivcensus.gatherer</groupId>
88
<artifactId>XIVStats-Gatherer-Java</artifactId>
9-
<version>v1.1.0</version>
9+
<version>v1.2.0</version>
1010
<name>XIVStats Lodestone Gatherer</name>
1111
<url>https://github.com/xivstats</url>
1212

@@ -155,6 +155,31 @@
155155
<artifactId>commons-cli</artifactId>
156156
<version>1.3.1</version>
157157
</dependency>
158+
<dependency>
159+
<groupId>org.apache.httpcomponents</groupId>
160+
<artifactId>httpclient</artifactId>
161+
<version>4.3.6</version>
162+
</dependency>
163+
<dependency>
164+
<groupId>org.apache.httpcomponents</groupId>
165+
<artifactId>httpasyncclient</artifactId>
166+
<version>4.0.2</version>
167+
</dependency>
168+
<dependency>
169+
<groupId>org.apache.httpcomponents</groupId>
170+
<artifactId>httpmime</artifactId>
171+
<version>4.3.6</version>
172+
</dependency>
173+
<dependency>
174+
<groupId>org.json</groupId>
175+
<artifactId>json</artifactId>
176+
<version>20140107</version>
177+
</dependency>
178+
<dependency>
179+
<groupId>com.mashape.unirest</groupId>
180+
<artifactId>unirest-java</artifactId>
181+
<version>1.4.9</version>
182+
</dependency>
158183
</dependencies>
159184

160185
</project>

src/main/java/com/ffxivcensus/gatherer/Console.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static GathererController run(String [] args){
2626
Options options = setupOptions();
2727

2828
//Declare usage string
29-
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]";
29+
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]";
3030
HelpFormatter formatter = new HelpFormatter();
3131

3232
try{
@@ -62,6 +62,12 @@ public static GathererController run(String [] args){
6262
//Store progression
6363
gatherer.setStoreProgression(!cmd.hasOption("b"));
6464

65+
//Store whether player is active
66+
gatherer.setStorePlayerActive(!cmd.hasOption("a"));
67+
68+
//Store player active date
69+
gatherer.setStoreActiveDate(!cmd.hasOption("D"));
70+
6571
//Database URL
6672
if(cmd.hasOption("d") && cmd.hasOption("U")){
6773
gatherer.setDbUrl("jdbc:" + cmd.getOptionValue("U") + "/" + cmd.getOptionValue("d"));
@@ -143,6 +149,8 @@ public static Options setupOptions(){
143149
Option optVerbose = Option.builder("v").longOpt("verbose").desc("run program in verbose bug mode - full console output").build();
144150
Option optFailPrint = Option.builder("F").longOpt("print-failures").desc("print records that don't exist").build();
145151
Option optSuffix = Option.builder("x").longOpt("suffix").hasArg().numberOfArgs(1).argName("table-suffix").desc("suffix to append to all tables").build();
152+
Option optStoreActive = Option.builder("a").longOpt("do-not-store-activity").desc("do not store boolean data indicating player activity in last 30 days").build();
153+
Option optStoreDate = Option.builder("D").longOpt("do-not-store-date").desc("do not store Date of last player activity").build();
146154

147155
//Add each option to the options object
148156
options.addOption(optStart);
@@ -162,6 +170,8 @@ public static Options setupOptions(){
162170
options.addOption(optVerbose);
163171
options.addOption(optFailPrint);
164172
options.addOption(optSuffix);
173+
options.addOption(optStoreActive);
174+
options.addOption(optStoreDate);
165175

166176
return options;
167177
}

src/main/java/com/ffxivcensus/gatherer/GathererController.java

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ public class GathererController {
9292
* Whether to output failed records
9393
*/
9494
private boolean printFails;
95+
/**
96+
* Whether to store player activity dates
97+
*/
98+
private boolean storeActiveDate;
99+
/**
100+
* Whether to store player activity bit
101+
*/
102+
private boolean storePlayerActive;
95103

96104
/**
97105
* List of playable realms (used when splitting tables).
@@ -228,6 +236,8 @@ public GathererController(int startId, int endId, boolean quiet, boolean verbose
228236
this.tableName = "tblplayers";
229237
this.tableSuffix = tableSuffix;
230238
this.splitTables = splitTables;
239+
this.storeActiveDate = true;
240+
this.storePlayerActive = true;
231241
}
232242

233243
/**
@@ -344,6 +354,14 @@ private void createTable(String tableName) {
344354
if (this.storeMinions) {
345355
sbSQL.append(",minions TEXT");
346356
}
357+
if(this.storeActiveDate) {
358+
sbSQL.append(",");
359+
sbSQL.append("date_active DATE");
360+
}
361+
if(this.storePlayerActive) {
362+
sbSQL.append(",");
363+
sbSQL.append("is_active BIT");
364+
}
347365
sbSQL.append(");");
348366

349367
st.executeUpdate(sbSQL.toString());
@@ -509,6 +527,25 @@ protected String writeToDB(Player player) {
509527
sbValues.append("\"" + player.getMountsString() + "\"");
510528
}
511529

530+
531+
if(this.storeActiveDate) {
532+
sbFields.append(",");
533+
sbValues.append(",");
534+
sbFields.append("date_active");
535+
java.util.Date dt = new java.util.Date();
536+
537+
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
538+
539+
String sqlDate = sdf.format(player.getDateImgLastModified());
540+
sbValues.append("\"" + sqlDate + "\"");
541+
}
542+
if(this.storePlayerActive) {
543+
sbFields.append(",");
544+
sbValues.append(",");
545+
sbFields.append("is_active");
546+
sbValues.append(player.getBitIsActive());
547+
}
548+
512549
sbFields.append(")");
513550
sbValues.append(");");
514551

@@ -734,7 +771,7 @@ public void setVerbose(boolean verbose) {
734771
}
735772
/**
736773
* Get list of realms to create tables for
737-
* @return
774+
* @return array of realm names
738775
*/
739776
public static String[] getRealms() {
740777
return realms;
@@ -787,4 +824,20 @@ public boolean isPrintFails() {
787824
public void setPrintFails(boolean printFails) {
788825
this.printFails = printFails;
789826
}
827+
828+
/**
829+
* Set whether to store the last active date of a character
830+
* @param storeActiveDate whether to store the last active date of a character
831+
*/
832+
public void setStoreActiveDate(boolean storeActiveDate) {
833+
this.storeActiveDate = storeActiveDate;
834+
}
835+
836+
/**
837+
* Set whether to store a boolean value indicating player activity
838+
* @param storePlayerActive whether to store a boolean value indicating player activity
839+
*/
840+
public void setStorePlayerActive(boolean storePlayerActive) {
841+
this.storePlayerActive = storePlayerActive;
842+
}
790843
}

0 commit comments

Comments
 (0)