simplify method
This commit is contained in:
@@ -42,7 +42,7 @@ public class ExpiredMessageTask implements Runnable {
|
|||||||
if(Cache.isVerbose()) LOGGER.info("expired check: {}", messageId);
|
if(Cache.isVerbose()) LOGGER.info("expired check: {}", messageId);
|
||||||
|
|
||||||
String expiryTimestamp = databaseSource.getQueuedExpiringMessageExpiryDate(messageId);
|
String expiryTimestamp = databaseSource.getQueuedExpiringMessageExpiryDate(messageId);
|
||||||
if(expiryTimestamp == null || expiryTimestamp.equals("")) // if missing timestamp
|
if(expiryTimestamp == null || expiryTimestamp.isEmpty()) // if missing timestamp
|
||||||
{
|
{
|
||||||
// count it as already expired
|
// count it as already expired
|
||||||
databaseSource.untrackExpiredMessage(messageId);
|
databaseSource.untrackExpiredMessage(messageId);
|
||||||
|
@@ -18,14 +18,14 @@ public class FormatUtil
|
|||||||
|
|
||||||
// cosmetic string to print on startup.
|
// cosmetic string to print on startup.
|
||||||
private static final String LOGO = """
|
private static final String LOGO = """
|
||||||
|
\s
|
||||||
██╗░░██╗██╗██████╗░███████╗██╗░░██╗░█████╗░
|
██╗░░██╗██╗██████╗░███████╗██╗░░██╗░█████╗░
|
||||||
██║░░██║██║██╔══██╗██╔════╝██║░██╔╝██╔══██╗
|
██║░░██║██║██╔══██╗██╔════╝██║░██╔╝██╔══██╗
|
||||||
███████║██║██║░░██║█████╗░░█████═╝░██║░░██║
|
███████║██║██║░░██║█████╗░░█████═╝░██║░░██║
|
||||||
██╔══██║██║██║░░██║██╔══╝░░██╔═██╗░██║░░██║
|
██╔══██║██║██║░░██║██╔══╝░░██╔═██╗░██║░░██║
|
||||||
██║░░██║██║██████╔╝███████╗██║░╚██╗╚█████╔╝
|
██║░░██║██║██████╔╝███████╗██║░╚██╗╚█████╔╝
|
||||||
╚═╝░░╚═╝╚═╝╚═════╝░╚══════╝╚═╝░░╚═╝░╚════╝░
|
╚═╝░░╚═╝╚═╝╚═════╝░╚══════╝╚═╝░░╚═╝░╚════╝░
|
||||||
""";
|
\s""";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,36 +60,26 @@ public class FormatUtil
|
|||||||
*
|
*
|
||||||
* @return the formatted String
|
* @return the formatted String
|
||||||
*/
|
*/
|
||||||
public static String getNiceDuration(Duration duration)
|
public static String getNiceDuration(Duration duration) {
|
||||||
{
|
|
||||||
long seconds = duration.toSecondsPart();
|
|
||||||
long minutes = duration.toMinutesPart();
|
|
||||||
long hours = duration.toHoursPart();
|
|
||||||
long days = duration.toDays();
|
long days = duration.toDays();
|
||||||
|
long hours = duration.toHoursPart();
|
||||||
|
long minutes = duration.toMinutesPart();
|
||||||
|
long seconds = duration.toSecondsPart();
|
||||||
|
|
||||||
StringBuilder uptimeStringBuilder = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if(days == 0)
|
if (days > 0) {
|
||||||
{
|
sb.append(days).append("d ");
|
||||||
if(hours == 0)
|
sb.append(hours).append("h ");
|
||||||
{
|
sb.append(minutes).append("m ");
|
||||||
if(minutes == 0)
|
} else if (hours > 0) {
|
||||||
{
|
sb.append(hours).append("h ");
|
||||||
// empty code block because it makes the code easier to read
|
sb.append(minutes).append("m ");
|
||||||
} else {
|
} else if (minutes > 0) {
|
||||||
uptimeStringBuilder.append(minutes).append("m ");
|
sb.append(minutes).append("m ");
|
||||||
}
|
}
|
||||||
} else {
|
sb.append(seconds).append("s");
|
||||||
uptimeStringBuilder.append(hours).append("h ");
|
|
||||||
uptimeStringBuilder.append(minutes).append("m ");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
uptimeStringBuilder.append(days).append("d ");
|
|
||||||
uptimeStringBuilder.append(hours).append("h ");
|
|
||||||
uptimeStringBuilder.append(minutes).append("m ");
|
|
||||||
}
|
|
||||||
uptimeStringBuilder.append(seconds).append("s ");
|
|
||||||
|
|
||||||
return uptimeStringBuilder.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user