From 8021bd0aaefc96d166fa2210b54a4719cb91b8f2 Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Thu, 15 Feb 2024 09:13:40 +0100 Subject: [PATCH] (control) Sort upload listing results Improve the UX of the sideload GUI by sorting the results in a sensible fashion, first by whether it's a directory, then by its filename. The change also changes the timestamp rendering to a more human-readable format than full ISO-8601. --- .../control/node/actions/partial-sideload-dirtree.hdb | 2 +- .../control/node/actions/partial-sideload-encyclopedia.hdb | 2 +- .../control/node/actions/partial-sideload-reddit.hdb | 4 ++-- .../control/node/actions/partial-sideload-stackexchange.hdb | 2 +- .../control/node/actions/partial-sideload-warc.hdb | 2 +- .../java/nu/marginalia/executor/svc/SideloadService.java | 6 +++++- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-dirtree.hdb b/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-dirtree.hdb index bcedeaa7..b620bfba 100644 --- a/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-dirtree.hdb +++ b/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-dirtree.hdb @@ -15,7 +15,7 @@ for more information on how to set this up. {{#unless directory}}{{size}}{{/unless}} - {{lastModifiedTime}} + {{shortTimestamp lastModifiedTime}} {{/each}} {{#unless uploadDirContents.items}} diff --git a/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-encyclopedia.hdb b/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-encyclopedia.hdb index 124f8a19..39d5c686 100644 --- a/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-encyclopedia.hdb +++ b/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-encyclopedia.hdb @@ -25,7 +25,7 @@ {{#unless directory}}{{size}}{{/unless}} - {{lastModifiedTime}} + {{shortTimestamp lastModifiedTime}} {{/each}} {{#unless uploadDirContents.items}} diff --git a/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-reddit.hdb b/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-reddit.hdb index 764be316..bf9f36b3 100644 --- a/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-reddit.hdb +++ b/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-reddit.hdb @@ -1,7 +1,7 @@

Sideload Reddit

-This will index a pushshift.io dump from the Reddit API into index. +This will index a pushshift.io "top-n subreddits" dump from the Reddit API into index.
@@ -14,7 +14,7 @@ This will index a pushshift.io dump from the Reddit API into index. {{#unless directory}}{{size}}{{/unless}} - {{lastModifiedTime}} + {{shortTimestamp lastModifiedTime}} {{/each}} {{#unless uploadDirContents.items}} diff --git a/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-stackexchange.hdb b/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-stackexchange.hdb index 8297ae68..f5f73f84 100644 --- a/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-stackexchange.hdb +++ b/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-stackexchange.hdb @@ -18,7 +18,7 @@ information how to do this. {{#unless directory}}{{size}}{{/unless}} - {{lastModifiedTime}} + {{shortTimestamp lastModifiedTime}} {{/each}} {{#unless uploadDirContents.items}} diff --git a/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-warc.hdb b/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-warc.hdb index 7871ca54..7680b7b8 100644 --- a/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-warc.hdb +++ b/code/services-core/control-service/src/main/resources/templates/control/node/actions/partial-sideload-warc.hdb @@ -17,7 +17,7 @@ A warc export can be created using e.g. wget:

{{#unless directory}}{{size}}{{/unless}} - {{lastModifiedTime}} + {{shortTimestamp lastModifiedTime}} {{/each}} {{#unless uploadDirContents.items}} diff --git a/code/services-core/executor-service/src/main/java/nu/marginalia/executor/svc/SideloadService.java b/code/services-core/executor-service/src/main/java/nu/marginalia/executor/svc/SideloadService.java index eae236c6..136b6f1d 100644 --- a/code/services-core/executor-service/src/main/java/nu/marginalia/executor/svc/SideloadService.java +++ b/code/services-core/executor-service/src/main/java/nu/marginalia/executor/svc/SideloadService.java @@ -16,6 +16,7 @@ import java.nio.file.Path; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; +import java.util.Comparator; public class SideloadService { private final ExecutorActorControlService actorControlService; @@ -61,7 +62,10 @@ public class SideloadService { public RpcUploadDirContents listUploadDir() throws IOException { Path uploadDir = WmsaHome.getUploadDir(); - try (var items = Files.list(uploadDir)) { + try (var items = Files.list(uploadDir).sorted( + Comparator.comparing((Path d) -> Files.isDirectory(d)).reversed() + .thenComparing(path -> path.getFileName().toString()) + )) { var builder = RpcUploadDirContents.newBuilder().setPath(uploadDir.toString()); var iter = items.iterator();