mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 13:09:00 +00:00
(control) Add better timestamps for the events and message queue views
Adjust display precision based on distance into the past, full ms-accurate timestamps available via hover-action.
This commit is contained in:
parent
81eaf79a25
commit
2fefd0e4e3
@ -1,12 +1,26 @@
|
||||
package nu.marginalia.control.sys.model;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public record EventLogEntry(
|
||||
long id,
|
||||
String serviceName,
|
||||
String instanceFull,
|
||||
String eventTime,
|
||||
String eventDateTime,
|
||||
String eventType,
|
||||
String eventMessage)
|
||||
{
|
||||
public String getEventTime() {
|
||||
String retDateBase = eventDateTime.replace('T', ' ');
|
||||
|
||||
// if another day, return date, hour and minute
|
||||
if (!eventDateTime.startsWith(LocalDate.now().toString())) {
|
||||
// return hour minute and seconds
|
||||
return retDateBase.substring(0, "YYYY-MM-DDTHH:MM".length());
|
||||
}
|
||||
else { // return date, hour and minute but not seconds or ms
|
||||
return retDateBase.substring("YYYY-MM-DDT".length(), "YYYY-MM-DDTHH:MM:SS".length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package nu.marginalia.control.sys.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public record MessageQueueEntry (
|
||||
long id,
|
||||
long relatedId,
|
||||
@ -10,7 +12,7 @@ public record MessageQueueEntry (
|
||||
String ownerInstanceFull,
|
||||
long ownerTick,
|
||||
String state,
|
||||
String createdTime,
|
||||
String updatedTimeFull,
|
||||
String updatedTime,
|
||||
int ttl
|
||||
)
|
||||
@ -32,4 +34,30 @@ public record MessageQueueEntry (
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
|
||||
public String getCreatedTime() {
|
||||
String retDateBase = updatedTimeFull.replace('T', ' ');
|
||||
|
||||
// if another day, return date, hour and minute
|
||||
if (!updatedTimeFull.startsWith(LocalDate.now().toString())) {
|
||||
// return hour minute and seconds
|
||||
return retDateBase.substring(0, "YYYY-MM-DDTHH:MM".length());
|
||||
}
|
||||
else { // return date, hour and minute but not seconds or ms
|
||||
return retDateBase.substring("YYYY-MM-DDT".length(), "YYYY-MM-DDTHH:MM:SS".length());
|
||||
}
|
||||
}
|
||||
|
||||
public String getUpdatedTime() {
|
||||
String retDateBase = updatedTimeFull.replace('T', ' ');
|
||||
|
||||
// if another day, return date, hour and minute
|
||||
if (!updatedTimeFull.startsWith(LocalDate.now().toString())) {
|
||||
// return hour minute and seconds
|
||||
return retDateBase.substring(0, "YYYY-MM-DDTHH:MM".length());
|
||||
}
|
||||
else { // return date, hour and minute but not seconds or ms
|
||||
return retDateBase.substring("YYYY-MM-DDT".length(), "YYYY-MM-DDTHH:MM:SS".length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import spark.Request;
|
||||
import spark.Response;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -108,7 +109,6 @@ public class EventLogService {
|
||||
rs.getLong("ID"),
|
||||
rs.getString("SERVICE_NAME"),
|
||||
rs.getString("INSTANCE"),
|
||||
rs.getTimestamp("EVENT_TIME").toLocalDateTime().toLocalTime().toString(),
|
||||
rs.getTimestamp("EVENT_TIME").toLocalDateTime().toString(),
|
||||
rs.getString("EVENT_TYPE"),
|
||||
rs.getString("EVENT_MESSAGE")
|
||||
@ -143,7 +143,6 @@ public class EventLogService {
|
||||
rs.getLong("ID"),
|
||||
rs.getString("SERVICE_NAME"),
|
||||
rs.getString("INSTANCE"),
|
||||
rs.getTimestamp("EVENT_TIME").toLocalDateTime().toLocalTime().toString(),
|
||||
rs.getTimestamp("EVENT_TIME").toLocalDateTime().toString(),
|
||||
rs.getString("EVENT_TYPE"),
|
||||
rs.getString("EVENT_MESSAGE")
|
||||
@ -155,6 +154,7 @@ public class EventLogService {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public List<EventLogEntry> getLastEntriesForTypeAndService(String typeName, String serviceName, long afterId, int n) {
|
||||
try (var conn = dataSource.getConnection();
|
||||
var query = conn.prepareStatement("""
|
||||
@ -178,7 +178,6 @@ public class EventLogService {
|
||||
rs.getLong("ID"),
|
||||
rs.getString("SERVICE_NAME"),
|
||||
rs.getString("INSTANCE"),
|
||||
rs.getTimestamp("EVENT_TIME").toLocalDateTime().toLocalTime().toString(),
|
||||
rs.getTimestamp("EVENT_TIME").toLocalDateTime().toString(),
|
||||
rs.getString("EVENT_TYPE"),
|
||||
rs.getString("EVENT_MESSAGE")
|
||||
@ -214,7 +213,6 @@ public class EventLogService {
|
||||
rs.getLong("ID"),
|
||||
rs.getString("SERVICE_NAME"),
|
||||
rs.getString("INSTANCE"),
|
||||
rs.getTimestamp("EVENT_TIME").toLocalDateTime().toLocalTime().toString(),
|
||||
rs.getTimestamp("EVENT_TIME").toLocalDateTime().toString(),
|
||||
rs.getString("EVENT_TYPE"),
|
||||
rs.getString("EVENT_MESSAGE")
|
||||
@ -247,7 +245,6 @@ public class EventLogService {
|
||||
rs.getLong("ID"),
|
||||
rs.getString("SERVICE_NAME"),
|
||||
rs.getString("INSTANCE"),
|
||||
rs.getTimestamp("EVENT_TIME").toLocalDateTime().toLocalTime().toString(),
|
||||
rs.getTimestamp("EVENT_TIME").toLocalDateTime().toString(),
|
||||
rs.getString("EVENT_TYPE"),
|
||||
rs.getString("EVENT_MESSAGE")
|
||||
|
@ -364,8 +364,8 @@ public class MessageQueueService {
|
||||
rs.getString("OWNER_INSTANCE"),
|
||||
rs.getLong("OWNER_TICK"),
|
||||
rs.getString("STATE"),
|
||||
rs.getTimestamp("CREATED_TIME").toLocalDateTime().toLocalTime().toString(),
|
||||
rs.getTimestamp("UPDATED_TIME").toLocalDateTime().toLocalTime().toString(),
|
||||
rs.getTimestamp("CREATED_TIME").toLocalDateTime().toString(),
|
||||
rs.getTimestamp("UPDATED_TIME").toLocalDateTime().toString(),
|
||||
rs.getInt("TTL"));
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@
|
||||
{{/unless}}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
{{> control/partials/foot-includes }}
|
||||
</html>
|
@ -44,7 +44,7 @@
|
||||
<td><a href="/message-queue?inbox={{recipientInbox}}">{{recipientInbox}}</a></td>
|
||||
<td>{{function}}</td>
|
||||
<td>{{{readableUUID ownerInstanceFull}}}</td>
|
||||
<td>{{createdTime}}</td>
|
||||
<td title="{{createdTimeFull}}">{{createdTime}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ttl}}</td>
|
||||
@ -56,9 +56,9 @@
|
||||
{{/if}}
|
||||
</td>
|
||||
<td><a href="/message-queue?inbox={{senderInbox}}">{{senderInbox}}</a></td>
|
||||
<td>{{payload}}</td>
|
||||
<td style="word-break: break-all; font-family: monospace;">{{payload}}</td>
|
||||
<td>{{ownerTick}}</td>
|
||||
<td>{{updatedTime}}</td>
|
||||
<td title="{{updatedTimeFull}}">{{updatedTime}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
<tfoot>
|
||||
|
Loading…
Reference in New Issue
Block a user