Skip to content

Commit

Permalink
Merge branch 'main' into asset-log
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenGnu committed Oct 15, 2024
2 parents f48effa + 1fc7aec commit 7a4a621
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@
<dependency>
<groupId>uk.me.candle</groupId>
<artifactId>pricing</artifactId>
<version>3.0.0</version>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>uk.me.candle</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/nikr/eve/jeveasset/LibraryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static synchronized Set<String> getLibFiles() {
files.add("guava-r09.jar");
files.add("LGoodDatePicker-11.2.1.jar");
files.add("jfreechart-1.5.3.jar");
files.add("pricing-3.0.0.jar");
files.add("pricing-3.1.1.jar");
files.add("routing-2.0.0.jar");
files.add("slf4j-api-1.7.36.jar");
files.add("log4j-over-slf4j-1.7.36.jar");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.swing.Icon;
import net.nikr.eve.jeveasset.gui.images.Images;
import net.nikr.eve.jeveasset.i18n.DataModelPriceDataSettings;
import uk.me.candle.eve.pricing.impl.Janice.JaniceLocation;
import uk.me.candle.eve.pricing.options.LocationType;
import uk.me.candle.eve.pricing.options.PriceType;
import uk.me.candle.eve.pricing.options.PricingFetch;
Expand All @@ -46,7 +47,7 @@ public enum PriceSource {
}
},
*/
JANICE(PricingFetch.JANICE, LocationType.STATION, 1L, Images.LINK_JANICE.getIcon()) {
JANICE(PricingFetch.JANICE, LocationType.STATION, JaniceLocation.JITA_4_4.getPriceLocation().getLocationID(), Images.LINK_JANICE.getIcon()) {
@Override String getI18N() {
return DataModelPriceDataSettings.get().sourceJanice();
}
Expand Down Expand Up @@ -118,6 +119,9 @@ public Icon getIcon() {

public boolean isValid(LocationType locationType, Long locationID) {
if (null != locationType && locationID != null) {
if (this == JANICE && !JaniceLocation.isValid(locationID)) {
return false;
}
switch (locationType) {
case REGION:
return supportRegions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,9 @@ private void updateSource(final PriceSource source) {
list.add(ApiIdConverter.getLocation(60005686));
} else if (source == PriceSource.JANICE) {
list = new ArrayList<>();
list.add(JaniceLocation.AMARR.getPriceLocation());
list.add(JaniceLocation.JITA_4_4.getPriceLocation());
list.add(JaniceLocation.JITA_4_4_AND_PERIMETER_TTT.getPriceLocation());
list.add(JaniceLocation.NPC.getPriceLocation());
list.add(JaniceLocation.PERIMETER_TTT.getPriceLocation());
for (JaniceLocation janiceLocation : JaniceLocation.values()) {
list.add(janiceLocation.getPriceLocation());
}
locationType = LocationType.STATION;
} else {
list = stations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public class PriceDataGetter implements PricingListener {
private static final int ATTEMPT_COUNT = 2;
private static final int ZERO_PRICES_WARNING_LIMIT = 10;
private static final int FAILED_PERCENT_CANCEL_LIMIT = 5;
private static final int ZERO_PERCENT_CANCEL_LIMIT = 25;

private UpdateTask updateTask;
private boolean update;
Expand Down Expand Up @@ -197,6 +196,9 @@ protected Map<Integer, PriceData> processUpdate(final UpdateTask task, final boo
pricingOptions.addHeader("X-ApiKey", janiceKey);
} else if (!JANICE.isEmpty()) {
pricingOptions.addHeader("X-ApiKey", JANICE);
} else if (updateTask != null) {
updateTask.addError("Price data", "No Janice API Key");
return null;
}
}

Expand Down Expand Up @@ -235,8 +237,9 @@ protected Map<Integer, PriceData> processUpdate(final UpdateTask task, final boo
return null;
}
}
boolean updated = (!okay.isEmpty() && (typeIDs.size() * FAILED_PERCENT_CANCEL_LIMIT / 100) > failed.size() && (typeIDs.size() * ZERO_PERCENT_CANCEL_LIMIT / 100) > zero.size());
if (updated && !failed.isEmpty()) {
boolean updated = !okay.isEmpty() && typeIDs.size() * FAILED_PERCENT_CANCEL_LIMIT / 100 > failed.size();

if (!failed.isEmpty()) {
StringBuilder errorString = new StringBuilder();
boolean first = true;
synchronized (failed) {
Expand All @@ -250,11 +253,11 @@ protected Map<Integer, PriceData> processUpdate(final UpdateTask task, final boo
}
}
LOG.error("Failed to update price data for the following typeIDs: " + errorString.toString());
if (updateTask != null) {
if (updated && updateTask != null) {
updateTask.addError("Price data", "Failed to update price data for " + failed.size() + " of " + typeIDs.size() + " item types");
}
}
if (updated && !zero.isEmpty()) {
if (!zero.isEmpty()) {
StringBuilder errorString = new StringBuilder();
synchronized (zero) {
boolean first = true;
Expand All @@ -268,7 +271,7 @@ protected Map<Integer, PriceData> processUpdate(final UpdateTask task, final boo
}
}
LOG.warn("Price data is zero for the following typeIDs: " + errorString.toString());
if (updateTask != null && zero.size() > ZERO_PRICES_WARNING_LIMIT) {
if (updated && updateTask != null && typeIDs.size() * ZERO_PRICES_WARNING_LIMIT / 100 < zero.size()) {
updateTask.addWarning("Price data", "Price data is zero for " + zero.size() + " of " + typeIDs.size() + " item types");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import uk.me.candle.eve.pricing.impl.Janice;
import uk.me.candle.eve.pricing.impl.Janice.JaniceLocation;
import uk.me.candle.eve.pricing.options.LocationType;
import uk.me.candle.eve.pricing.options.NamedPriceLocation;
import uk.me.candle.eve.pricing.options.PriceLocation;
import uk.me.candle.eve.pricing.options.PricingOptions;

Expand Down Expand Up @@ -119,19 +120,22 @@ private void test(PriceSource source) {
}
if (source.supportStations()) {
if (source == PriceSource.JANICE) {
test(source, LocationType.STATION, Janice.JaniceLocation.JITA_4_4.getPriceLocation());
for (JaniceLocation location : JaniceLocation.values()) {
test(source, LocationType.STATION, location.getPriceLocation());
}
} else {
test(source, LocationType.STATION, ApiIdConverter.getLocation(STATION_JITA_4_4));
}
}
}

private void test(PriceSource source, LocationType locationType, PriceLocation location) {
private void test(PriceSource source, LocationType locationType, NamedPriceLocation location) {
TestPricingOptions options = new TestPricingOptions(locationType, location);
System.out.println(source.toString()
+ " ("
+ options.getLocationType().name().toLowerCase()
+ " - " +typeIDs.size() + " IDs)"
+ " - " + location.getLocation()
+ " - " + typeIDs.size() + " IDs)"
);
if (source == PriceSource.JANICE && JANICE_KEY != null) {
options.addHeader("X-ApiKey", JANICE_KEY);
Expand Down Expand Up @@ -175,7 +179,7 @@ public TestPricingOptions(LocationType locationType, PriceLocation location) {

@Override
public long getPriceCacheTimer() {
return 60*60*1000l; // 1 hour
return 60*60*1000L; // 1 hour
}

@Override
Expand All @@ -200,7 +204,7 @@ public OutputStream getCacheOutputStream() throws IOException {

@Override
public boolean getCacheTimersEnabled() {
return true;
return false;
}

@Override
Expand Down

0 comments on commit 7a4a621

Please sign in to comment.