use of io.datarouter.clustersetting.web.dto.ClusterSettingLogJspDto in project datarouter by hotpads.
the class ClusterSettingsHandler method logsForAll.
@Handler
public Mav logsForAll(OptionalString explicitStartIso, OptionalBoolean inclusiveStart) {
Mav mav = new Mav(files.jsp.admin.datarouter.setting.clusterSettingsLogJsp);
mav.put("showingAllSettings", true);
long startCreatedMs = explicitStartIso.map(isoDate -> LocalDateTime.parse(isoDate, DateTimeFormatter.ISO_LOCAL_DATE_TIME)).map(localDate -> localDate.atZone(ZoneId.systemDefault())).map(ZonedDateTime::toInstant).map(Instant::toEpochMilli).orElseGet(System::currentTimeMillis);
long reverseStartCreatedMs = Long.MAX_VALUE - startCreatedMs;
Range<ClusterSettingLogByReversedCreatedMsKey> range = new Range<>(new ClusterSettingLogByReversedCreatedMsKey(reverseStartCreatedMs, null), inclusiveStart.orElse(false));
clusterSettingLogDao.scanByReversedCreatedMs(range, CLUSTER_SETTING_LOGS_PAGE_SIZE).map(setting -> new ClusterSettingLogJspDto(setting, getUserZoneId())).flush(logs -> mav.put("logs", logs)).flush(logs -> mav.put("hasNextPage", logs.size() == CLUSTER_SETTING_LOGS_PAGE_SIZE));
mav.put("hasPreviousPage", explicitStartIso.isPresent());
return mav;
}
use of io.datarouter.clustersetting.web.dto.ClusterSettingLogJspDto in project datarouter by hotpads.
the class ClusterSettingsHandler method logsForName.
@Handler
public Mav logsForName(String name) {
Mav mav = new Mav(files.jsp.admin.datarouter.setting.clusterSettingsLogJsp);
mav.put("showingAllSettings", false);
String settingName = name.endsWith(".") ? StringTool.getStringBeforeLastOccurrence('.', name) : name;
mav.put("nameParts", settingName.split("\\."));
Optional<SettingNode> node = getSettingNode(settingName);
mav.put("showingNodeSettings", node.isPresent());
Scanner<ClusterSettingLog> logScanner;
if (node.isPresent()) {
// logs for node and its descendants
List<ClusterSettingLogKey> prefixes = node.get().getListSettings().stream().map(Setting::getName).map(ClusterSettingLogKey::createPrefix).collect(Collectors.toList());
logScanner = clusterSettingLogDao.scanWithPrefixes(prefixes).sort(Comparator.comparing((ClusterSettingLog log) -> log.getKey().getCreated()).reversed());
} else {
// logs for single setting
ClusterSettingLogKey prefix = ClusterSettingLogKey.createPrefix(settingName);
logScanner = clusterSettingLogDao.scanWithPrefix(prefix);
}
logScanner.map(setting -> new ClusterSettingLogJspDto(setting, getUserZoneId())).flush(logs -> mav.put("logs", logs));
return mav;
}
Aggregations