Skip to content

Commit ab180f3

Browse files
committed
[#1] Added flags for storing activity data
1 parent e56e485 commit ab180f3

File tree

4 files changed

+90
-21
lines changed

4 files changed

+90
-21
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

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: 46 additions & 0 deletions
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).
@@ -344,6 +352,14 @@ private void createTable(String tableName) {
344352
if (this.storeMinions) {
345353
sbSQL.append(",minions TEXT");
346354
}
355+
if(this.storeActiveDate) {
356+
sbSQL.append(",");
357+
sbSQL.append("date_active DATE");
358+
}
359+
if(this.storePlayerActive) {
360+
sbSQL.append(",");
361+
sbSQL.append("is_active BIT");
362+
}
347363
sbSQL.append(");");
348364

349365
st.executeUpdate(sbSQL.toString());
@@ -509,6 +525,20 @@ protected String writeToDB(Player player) {
509525
sbValues.append("\"" + player.getMountsString() + "\"");
510526
}
511527

528+
529+
if(this.storeActiveDate) {
530+
sbFields.append(",");
531+
sbValues.append(",");
532+
sbFields.append("date_active");
533+
sbValues.append(player.getDateImgLastModified());
534+
}
535+
if(this.storePlayerActive) {
536+
sbFields.append(",");
537+
sbValues.append(",");
538+
sbFields.append("is_active");
539+
sbValues.append(player.getBitIsActive());
540+
}
541+
512542
sbFields.append(")");
513543
sbValues.append(");");
514544

@@ -787,4 +817,20 @@ public boolean isPrintFails() {
787817
public void setPrintFails(boolean printFails) {
788818
this.printFails = printFails;
789819
}
820+
821+
/**
822+
* Set whether to store the last active date of a character
823+
* @param storeActiveDate whether to store the last active date of a character
824+
*/
825+
public void setStoreActiveDate(boolean storeActiveDate) {
826+
this.storeActiveDate = storeActiveDate;
827+
}
828+
829+
/**
830+
* Set whether to store a boolean value indicating player activity
831+
* @param storePlayerActive whether to store a boolean value indicating player activity
832+
*/
833+
public void setStorePlayerActive(boolean storePlayerActive) {
834+
this.storePlayerActive = storePlayerActive;
835+
}
790836
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,6 +2176,15 @@ public boolean isActive() {
21762176
return isActive;
21772177
}
21782178

2179+
/**
2180+
* Get whether a Player is active
2181+
* @return whether Player is active
2182+
*/
2183+
public int getBitIsActive() {
2184+
if(this.isActive) return 1;
2185+
return 0;
2186+
}
2187+
21792188
/**
21802189
* Set whether Player is active
21812190
* @param active whether player is considered active

0 commit comments

Comments
 (0)