forked from SteamWar/SteamWar
Merge pull request 'Refactor schematic checks to handle unseen notifications' (#33) from add-offline-notify into main
Reviewed-on: SteamWar/SteamWar#33 Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
This commit is contained in:
@@ -37,15 +37,14 @@ public class CheckedSchematic {
|
||||
private static final SelectStatement<CheckedSchematic> nodeHistory = new SelectStatement<>(table, "SELECT * FROM CheckedSchematic WHERE NodeId = ? AND DeclineReason != '' AND DeclineReason != 'Prüfvorgang abgebrochen' ORDER BY EndTime DESC");
|
||||
private static final Statement insert = table.insertAll();
|
||||
|
||||
public static void create(int nodeId, String name, int owner, int validator, Timestamp startTime, Timestamp endTime, String reason){
|
||||
insert.update(nodeId, owner, name, validator, startTime, endTime, reason);
|
||||
private static final SelectStatement<CheckedSchematic> getUnseen = new SelectStatement<>(table, "SELECT * FROM CheckedSchematic WHERE Seen = 0 AND NodeOwner = ? ORDER BY StartTime DESC");
|
||||
private static final Statement updateSeen = new Statement("UPDATE CheckedSchematic SET Seen = ? WHERE StartTime = ? AND EndTime = ? AND NodeName = ?");
|
||||
|
||||
public static void create(SchematicNode node, int validator, Timestamp startTime, Timestamp endTime, String reason, boolean seen) {
|
||||
insert.update(node.getId(), node.getName(), node.getOwner(), validator, startTime, endTime, reason, seen, node.getSchemtype().toDB());
|
||||
}
|
||||
|
||||
public static void create(SchematicNode node, int validator, Timestamp startTime, Timestamp endTime, String reason){
|
||||
create(node.getId(), node.getName(), node.getOwner(), validator, startTime, endTime, reason);
|
||||
}
|
||||
|
||||
public static List<CheckedSchematic> getLastDeclinedOfNode(int node){
|
||||
public static List<CheckedSchematic> getLastDeclinedOfNode(int node) {
|
||||
return statusOfNode.listSelect(node);
|
||||
}
|
||||
|
||||
@@ -53,6 +52,10 @@ public class CheckedSchematic {
|
||||
return nodeHistory.listSelect(node.getId());
|
||||
}
|
||||
|
||||
public static List<CheckedSchematic> getUnseen(SteamwarUser owner) {
|
||||
return getUnseen.listSelect(owner);
|
||||
}
|
||||
|
||||
@Field(nullable = true)
|
||||
private final Integer nodeId;
|
||||
@Field
|
||||
@@ -71,6 +74,10 @@ public class CheckedSchematic {
|
||||
@Getter
|
||||
@Field
|
||||
private final String declineReason;
|
||||
@Getter
|
||||
private boolean seen;
|
||||
@Getter
|
||||
private final String nodeType;
|
||||
|
||||
public int getNode() {
|
||||
return nodeId;
|
||||
@@ -83,4 +90,9 @@ public class CheckedSchematic {
|
||||
public int getSchemOwner() {
|
||||
return nodeOwner;
|
||||
}
|
||||
|
||||
public void setSeen(boolean seen) {
|
||||
this.seen = seen;
|
||||
updateSeen.update(seen, startTime, endTime, nodeName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user