Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Db size info (#82)
Browse files Browse the repository at this point in the history
* Added alert when clearing the DB and added info about DB size

* Updated version info
  • Loading branch information
Fi0x committed Feb 27, 2022
1 parent d19c9ae commit 9ac919f
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 7 deletions.
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>com.fi0x.edct</groupId>
<artifactId>EliteDangerousCarrierTrader</artifactId>
<!-- //TODO: update version -->
<version>1.6.9.9</version>
<version>1.7.10.9</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand Down
2 changes: 1 addition & 1 deletion setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

; TODO: Update Version info
#define MyAppName "Elite Dangerous Carrier Trader"
#define MyAppVersion "1.6.9.9"
#define MyAppVersion "1.7.10.9"
#define MyAppPublisher "Fi0x"
#define MyAppURL "https://github.com/Fi0x/EDCT"
#define MyAppExeName "EDCT.exe"
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/fi0x/edct/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class Main
public static File reddit;
public static File discord;
//TODO: Update version information
public static final String version = "1.6.9.9";//All.GUI.Logic.Hotfix
public static final String version = "1.7.10.9";//All.GUI.Logic.Hotfix
public static final VersionType versionType = VersionType.INSTALLER;

public static void main(String[] args)
Expand Down
24 changes: 20 additions & 4 deletions src/main/java/com/fi0x/edct/gui/controller/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
import com.fi0x.edct.logic.threads.Updater;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
import javafx.scene.control.*;
import javafx.scene.layout.VBox;
import org.apache.commons.io.FileUtils;

Expand Down Expand Up @@ -181,7 +178,23 @@ private void clearLogs()
private void clearDB()
{
MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("clear-DB"));

int stationEntries = DBHandler.countStationEntries();
int tradeEntries = DBHandler.countTradeEntries();

String alertText = "Are you sure you want to clear the database?";
if(stationEntries > 0) alertText += " It contains " + stationEntries + " stations";
else if(tradeEntries > 0) alertText += " It contains " + tradeEntries + " trades";
if(stationEntries > 0 && tradeEntries > 0) alertText += " and " + tradeEntries + " trades";

Alert alert = new Alert(Alert.AlertType.WARNING, alertText, ButtonType.YES, ButtonType.CANCEL);
alert.showAndWait();

if(alert.getResult() == ButtonType.CANCEL)
return;

DBHandler.removeTradeData();
DBHandler.removeStationDATA();

if(Main.eddn != null) Main.eddn.interrupt();
if(Main.updater != null) Main.updater.interrupt();
Expand All @@ -192,16 +205,19 @@ private void clearDB()
@FXML
private void openBlacklist()
{
MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("open-blacklist"));
ExternalProgram.openNotepad(Main.blacklist);
}
@FXML
private void openRedditConfig()
{
MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("open-reddit-config"));
ExternalProgram.openNotepad(Main.reddit);
}
@FXML
private void openDiscordConfig()
{
MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("open-discord-config"));
ExternalProgram.openNotepad(Main.discord);
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/fi0x/edct/gui/controller/Station.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fi0x.edct.gui.controller;

import com.fi0x.edct.logging.Logger;
import com.fi0x.edct.logging.MixpanelHandler;
import com.fi0x.edct.logic.database.DBHandler;
import com.fi0x.edct.logic.filesystem.BlacklistHandler;
import com.fi0x.edct.logic.helper.ConvertToString;
Expand Down Expand Up @@ -76,6 +77,8 @@ public void initialize(URL url, ResourceBundle resourceBundle)

btnReddit.addEventHandler(MouseEvent.MOUSE_CLICKED, e ->
{
MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("copy-reddit-string"));

TRADE station = isBuying ? resultsController.getCurrentBuyStation() : resultsController.getCurrentSellStation();
String text;
if(e.getButton() == MouseButton.SECONDARY) text = ConvertToString.redditContent(resultsController, station, isBuying);
Expand All @@ -91,6 +94,8 @@ public void initialize(URL url, ResourceBundle resourceBundle)
});
btnDiscord.addEventHandler(MouseEvent.MOUSE_CLICKED, e ->
{
MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("copy-discord-string"));

TRADE station = isBuying ? resultsController.getCurrentBuyStation() : resultsController.getCurrentSellStation();
String text = ConvertToString.discordText(resultsController, station, isBuying);

Expand Down Expand Up @@ -136,20 +141,26 @@ private void previousStation()
@FXML
private void reloadStation()
{
MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("reload-station-data"));

TRADE currentTrade = isBuying ? resultsController.getCurrentBuyStation() : resultsController.getCurrentSellStation();
InaraStation.updateSingleStationTrades(stationName, stationSystem, currentTrade);
resultsController.displayResults();
}
@FXML
private void addToBlacklist()
{
MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("add-station-to-blacklist"));

TRADE s = isBuying ? resultsController.getCurrentBuyStation() : resultsController.getCurrentSellStation();
BlacklistHandler.addSystemToBlacklist(s.STATION.SYSTEM);
resultsController.mainController.updateFilters();
}
@FXML
private void removeStation()
{
MixpanelHandler.addMessage(MixpanelHandler.EVENT.BUTTON_CLICKED, MixpanelHandler.getButtonProperty("remove-station-temporary"));

TRADE s = isBuying ? resultsController.getCurrentBuyStation() : resultsController.getCurrentSellStation();
int commodityID = DBHandler.getCommodityIDByName(resultsController.getCurrentTrade().NAME);
DBHandler.removeStationEntry(commodityID, s.STATION.NAME, s.STATION.SYSTEM, !isBuying);
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/com/fi0x/edct/logic/database/DBHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,47 @@ public static void removeOldEntries()
"WHERE Age < " + validTime);
}

public static int countStationEntries()
{
ResultSet results = getQueryResults("SELECT COUNT(StarDistance) " +
"FROM Stations");

try
{
if(results != null && results.next())
return results.getInt(1);
} catch(SQLException e)
{
Logger.WARNING("Could not count the rows of the Stations table", e);
}

return -1;
}
public static int countTradeEntries()
{
ResultSet results = getQueryResults("SELECT COUNT(InaraID) " +
"FROM Trades");

try
{
if(results != null && results.next())
return results.getInt(1);
} catch(SQLException e)
{
Logger.WARNING("Could not count the rows of the Trades table", e);
}

return -1;
}

public static void removeTradeData()
{
sendStatement("DELETE FROM Trades");
}
public static void removeStationDATA()
{
sendStatement("DELETE FROM Stations");
}

private static synchronized void sendStatement(String command)
{
Expand Down

0 comments on commit 9ac919f

Please sign in to comment.