Skip to content

Commit

Permalink
Watchlist Feature
Browse files Browse the repository at this point in the history
  • Loading branch information
isuretpolos committed Jul 18, 2023
1 parent a29697d commit 84b0a74
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
temporaryDashboardText.txt

watchlist.csv
/target/
/hotbits/
/cases/
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/de/isuret/polos/AetherOnePi/domain/Rate.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package de.isuret.polos.AetherOnePi.domain;

import java.util.ArrayList;
import java.util.List;

/**
* A rate from a database
*/
Expand Down Expand Up @@ -27,6 +30,8 @@ public class Rate {

private byte[] base64File;

private List<Rate> subRates = new ArrayList<>();

public Long getId() {
return id;
}
Expand Down Expand Up @@ -90,4 +95,8 @@ public byte[] getBase64File() {
public void setBase64File(byte[] base64File) {
this.base64File = base64File;
}

public List<Rate> getSubRates() {
return subRates;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import de.isuret.polos.AetherOnePi.utils.AetherOnePiProcessingConfiguration;
import de.isuret.polos.AetherOnePi.utils.CaseToHtml;
import io.javalin.http.staticfiles.Location;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -76,6 +77,10 @@ public class AetherOneUI extends PApplet {
private AetherOneServer aetherOneServer;
private Logger logger = LoggerFactory.getLogger(AetherOneUI.class);

private List<Rate> watchlist = new ArrayList<>();
public AnalysisResult watchlistAnalysis;
public boolean watchlistRequiresAttention = false;

public static void main(String[] args) {
AetherOneUI.main(AetherOneUI.class.getName());
}
Expand Down Expand Up @@ -156,6 +161,7 @@ public void setTitle(String title) {
}

public void setup() {

background(200);

AetherOneUI ui = this;
Expand Down Expand Up @@ -332,14 +338,58 @@ public void run() {

hotbitsHandler.loadHotbits();
aetherOneServer = new AetherOneServer(Location.CLASSPATH, this);

File watchlistFile = new File("watchlist.csv");

if (watchlistFile.exists()) {
try {
List<String> lines = FileUtils.readLines(watchlistFile, "UTF-8");
lines.stream().forEach(s -> {
Rate rate = new Rate();

if (s.contains(",")) {
String[] parts = s.split(",");
for (int i = 0; i < parts.length; i++)
if (i == 0) {
rate.setName(parts[i]);
} else {
Rate subRate = new Rate();
subRate.setName(parts[i]);
rate.getSubRates().add(subRate);
}
} else {
rate.setName(s);
}

watchlist.add(rate);
});

logger.info("Reading watchlist.csv successful! " + watchlist.size() + " entries read!");
watchlistAnalysis = analyseService.analyseRateList(watchlist);
watchlistAnalysis.getRateObjects().forEach( r -> {
r.setGv(checkGeneralVitalityValue());
});
Collections.sort(watchlistAnalysis.getRateObjects(), (o1, o2) -> {
return o1.getGv().compareTo(o2.getGv());
});
for (RateObject rate : watchlistAnalysis.getRateObjects()) {
if (rate.getGv() < 500) {
watchlistRequiresAttention = true;
break;
}
}
} catch (IOException e) {
logger.error("Error reading watchlist CSV file!", e);
}
}
}

public void draw() {
guiElements.draw();

if (clearUv > 0) {
clearUv = clearUv - 1;
if(clearUv % 2 == 0) {
if (clearUv % 2 == 0) {
fill(238, 0, 255);
rect(0, 0, width, height);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.isuret.polos.AetherOnePi.processing2.elements;

import de.isuret.polos.AetherOnePi.domain.RateObject;
import de.isuret.polos.AetherOnePi.processing2.AetherOneUI;

public class DashboardElement implements IDrawableElement {
Expand Down Expand Up @@ -27,6 +28,22 @@ public void draw() {
y += 20;
}
}

if (p.watchlistRequiresAttention) {

p.stroke(255);
y = 100;
p.text("WATCHLIST REQUIRES ATTENTION", 600, y);
p.line(600,y+2,1000,y+2);

for (RateObject rate : p.watchlistAnalysis.getRateObjects()) {
if (rate.getGv() < 500) {
y += 20;
p.text(rate.getNameOrRate(), 660, y);
p.text(rate.getGv(), 600, y);
}
}
}
}

@Override
Expand Down

0 comments on commit 84b0a74

Please sign in to comment.