Skip to content

Commit

Permalink
Add SubcategoryID and SubcategoryName to mod search database
Browse files Browse the repository at this point in the history
  • Loading branch information
maddie480 committed Jun 23, 2024
1 parent 3c0a5ab commit 63ce6cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Get Maven, then run the following command at the project root:
mvn clean package
```

This will build the project to `target/update-checker-0.7.0.jar`.
This will build the project to `target/update-checker-0.7.2.jar`.

### Running the project

Expand All @@ -213,7 +213,7 @@ First, follow these steps to set it up:
Then, to run the project, browse to where the JAR is in a terminal / command prompt, then run

```
java -jar update-checker-0.7.0.jar [minutes]
java -jar update-checker-0.7.2.jar [minutes]
```
[minutes] is the wait delay in minutes between two GameBanana checks (defaults to 30). Be aware that the program makes ~13 API calls per check, and that the GameBanana API has a cap at 250 requests/hour.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ovh.maddie480.everest.updatechecker</groupId>
<artifactId>update-checker</artifactId>
<version>0.7.0</version>
<version>0.7.2</version>

<properties>
<jdk.version>21</jdk.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ private static class ModSearchInfo {
private final int downloads;
private int categoryId;
private String categoryName;
private Integer subcategoryId;
private String subcategoryName;
private final long createdDate;
private final long modifiedDate;
private final long updatedDate;
Expand Down Expand Up @@ -107,6 +109,10 @@ public Map<String, Object> toMap() {
if (featured != null) {
map.put("Featured", featured);
}
if (subcategoryId != null) {
map.put("SubcategoryId", subcategoryId);
map.put("SubcategoryName", subcategoryName);
}
return map;
}
}
Expand Down Expand Up @@ -285,11 +291,11 @@ private void assignCategoryNamesToMods(String itemtype) throws IOException {

for (Object categoryRaw : listOfCategories) {
JSONObject category = (JSONObject) categoryRaw;
categoryNames.put(category.getInt("_idRow"), category.getString("_sName"));

if (category.getInt("_idParentCategoryRow") == 0) {
// this is a root category!
log.trace("{} ({}) is a root category", category.getInt("_idRow"), category.getString("_sName"));
categoryNames.put(category.getInt("_idRow"), category.getString("_sName"));
} else {
// this is a subcategory.
log.trace("{} ({}) is the child of category {}", category.getInt("_idRow"), category.getString("_sName"), category.getInt("_idParentCategoryRow"));
Expand All @@ -307,9 +313,14 @@ private void assignCategoryNamesToMods(String itemtype) throws IOException {
category = categoryToParent.get(category);
}

log.trace("Reassigning category {} of {} {} to {} ({})", info.categoryId, info.gameBananaType, info.gameBananaId, category, categoryNames.get(category));

// assign it.
if (info.categoryId != category) {
log.trace("Assigning subcategory of {} {} to {} ({})", info.gameBananaType, info.gameBananaId, info.categoryId, categoryNames.get(info.categoryId));
info.subcategoryId = info.categoryId;
info.subcategoryName = categoryNames.get(info.categoryId);
}

log.trace("Reassigning category {} of {} {} to {} ({})", info.categoryId, info.gameBananaType, info.gameBananaId, category, categoryNames.get(category));
info.categoryId = category;
info.categoryName = categoryNames.get(category);
}
Expand Down

0 comments on commit 63ce6cc

Please sign in to comment.