Skip to content

Commit 523f79b

Browse files
committed
Remove useless per-item fetch and add real User-Agent
1 parent b5b9332 commit 523f79b

File tree

4 files changed

+8
-76
lines changed

4 files changed

+8
-76
lines changed

src/main/java/me/alexpresso/zuninja/classes/item/ItemDetail.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/main/java/me/alexpresso/zuninja/services/item/ItemService.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package me.alexpresso.zuninja.services.item;
22

3-
import me.alexpresso.zuninja.classes.item.ItemDetail;
43
import me.alexpresso.zuninja.domain.nodes.item.Fusion;
54
import me.alexpresso.zuninja.domain.nodes.item.Item;
65

@@ -11,8 +10,6 @@
1110
public interface ItemService {
1211
List<Item> fetchItems() throws IOException, InterruptedException;
1312

14-
ItemDetail fetchItemDetail(Item item) throws IOException, InterruptedException;
15-
1613
List<Item> getItems();
1714

1815
Map<String, Item> updateItems() throws IOException, InterruptedException;

src/main/java/me/alexpresso/zuninja/services/item/ItemServiceImpl.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package me.alexpresso.zuninja.services.item;
22

33
import com.fasterxml.jackson.core.type.TypeReference;
4-
import me.alexpresso.zuninja.classes.item.ItemDetail;
54
import me.alexpresso.zuninja.domain.nodes.item.Fusion;
65
import me.alexpresso.zuninja.domain.nodes.item.Item;
76
import me.alexpresso.zuninja.domain.nodes.item.Pack;
@@ -46,11 +45,6 @@ public List<Item> fetchItems() throws IOException, InterruptedException {
4645
return (List<Item>) this.requestService.request("/public/item", "GET", new TypeReference<List<Item>>() {});
4746
}
4847

49-
@Override
50-
public ItemDetail fetchItemDetail(final Item item) throws IOException, InterruptedException {
51-
return (ItemDetail) this.requestService.request(String.format("/public/item/%s", item.getSlug()), "GET", new TypeReference<ItemDetail>(){});
52-
}
53-
5448
@Override
5549
public List<Item> getItems() {
5650
return this.itemRepository.findAll();
@@ -73,21 +67,19 @@ public Map<String, Item> updateItems() throws IOException, InterruptedException
7367

7468
items.parallelStream().forEach(item -> {
7569
try {
76-
final var detail = this.fetchItemDetail(item);
77-
7870
dbItems.put(item.getId(), dbItems.getOrDefault(item.getId(), item)
7971
.setPack(packs.get(item.getPack().getId()))
8072
.setGenre(item.getGenre())
8173
.setName(item.getName())
8274
.setRarity(item.getRarity())
8375
.setSlug(item.getSlug())
84-
.setCounting(detail.isCounting())
85-
.setCraftable(detail.isCraftable())
86-
.setInvocable(detail.isInvocable())
87-
.setRecyclable(detail.isRecyclable())
88-
.setTradable(detail.isTradable())
89-
.setGoldable(detail.isGoldable())
90-
.setUpgradable(detail.isUpgradable())
76+
.setCounting(item.isCounting())
77+
.setCraftable(item.isCraftable())
78+
.setInvocable(item.isInvocable())
79+
.setRecyclable(item.isRecyclable())
80+
.setTradable(item.isTradable())
81+
.setGoldable(item.isGoldable())
82+
.setUpgradable(item.isUpgradable())
9183
);
9284

9385
logger.info("({}/{}) Updated {} ", count.getAndIncrement(), items.size(), item.getName());

src/main/java/me/alexpresso/zuninja/services/request/RequestServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public Object request(final String uri, final String method, final Object data,
5454
"sec-fetch-dest", "empty",
5555
"sec-fetch-mode", "cors",
5656
"sec-fetch-site", "same-site",
57-
"user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36",
57+
"user-agent", "github.com/alexpresso/zunivers-ninja",
5858
"x-zunivers-rulesettype", this.gameMode.name()
5959
).uri(URI.create(String.format("https://%s%s", this.apiBaseUrl, uri)));
6060

0 commit comments

Comments
 (0)