mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
refactor(core): remove remaining epoch timestamp wrappers (#7167)
This commit is contained in:
1 parent
e90f2590b5
commit
8edbc10b71
5 files changed
+21
-30
No files matched your search
+5
-7
@@ -349,15 +349,16 @@ public class RedshiftServerlessAdminJsonHandler {
|
||||
private ObjectNode scheduledActionNode(ScheduledAction action) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
if (action.getEndTime() != null) {
|
||||
node.put("endTime", epoch(action.getEndTime()));
|
||||
node.put("endTime", EpochSeconds.fromInstant(action.getEndTime()));
|
||||
}
|
||||
node.put("namespaceName", action.getNamespaceName());
|
||||
ArrayNode invocations = node.putArray("nextInvocations");
|
||||
RedshiftServerlessSchedule.next(action, Instant.now()).ifPresent(time -> invocations.add(epoch(time)));
|
||||
RedshiftServerlessSchedule.next(action, Instant.now())
|
||||
.ifPresent(time -> invocations.add(EpochSeconds.fromInstant(time)));
|
||||
node.put("roleArn", action.getRoleArn());
|
||||
ObjectNode schedule = node.putObject("schedule");
|
||||
if (action.getScheduleAt() != null) {
|
||||
schedule.put("at", epoch(action.getScheduleAt()));
|
||||
schedule.put("at", EpochSeconds.fromInstant(action.getScheduleAt()));
|
||||
} else {
|
||||
schedule.put("cron", action.getScheduleCron());
|
||||
}
|
||||
@@ -367,7 +368,7 @@ public class RedshiftServerlessAdminJsonHandler {
|
||||
node.put("scheduledActionName", action.getScheduledActionName());
|
||||
node.put("scheduledActionUuid", action.getScheduledActionUuid());
|
||||
if (action.getStartTime() != null) {
|
||||
node.put("startTime", epoch(action.getStartTime()));
|
||||
node.put("startTime", EpochSeconds.fromInstant(action.getStartTime()));
|
||||
}
|
||||
node.put("state", Boolean.FALSE.equals(action.getEnabled()) ? "DISABLED" : "ACTIVE");
|
||||
ObjectNode createSnapshot = node.putObject("targetAction").putObject("createSnapshot");
|
||||
@@ -387,9 +388,6 @@ public class RedshiftServerlessAdminJsonHandler {
|
||||
return node;
|
||||
}
|
||||
|
||||
private static double epoch(Instant instant) {
|
||||
return EpochSeconds.fromInstant(instant);
|
||||
}
|
||||
// ── Tracks, managed workgroups and reservations ────────────────────────
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.SmithyValidationErrors;
|
||||
import io.github.hectorvent.floci.services.ses.model.SentEmail;
|
||||
@@ -31,7 +32,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.epochSeconds;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.readOptionBody;
|
||||
|
||||
/**
|
||||
@@ -153,7 +153,7 @@ public class SesMetricsController {
|
||||
node.put("Id", query.id());
|
||||
ArrayNode timestamps = node.putArray("Timestamps");
|
||||
for (Instant timestamp : series.timestamps()) {
|
||||
timestamps.add(epochSeconds(timestamp));
|
||||
timestamps.add(EpochSeconds.fromInstant(timestamp));
|
||||
}
|
||||
ArrayNode values = node.putArray("Values");
|
||||
for (Long value : series.values()) {
|
||||
|
||||
@@ -353,18 +353,9 @@ final class SesV2Json {
|
||||
return coerceBoolean(enabledNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Epoch seconds with the millisecond fraction, the shape AWS returns for every SES v2
|
||||
* timestamp (probe-confirmed, e.g. {@code 1.790312384592E9}). It must stay a JSON number: an
|
||||
* ISO string, as the v1 Query path writes, breaks the SDK's unixTimestamp unmarshaller.
|
||||
*/
|
||||
static double epochSeconds(Instant instant) {
|
||||
return EpochSeconds.fromInstant(instant);
|
||||
}
|
||||
|
||||
static void putTimestamp(ObjectNode node, String field, Instant value) {
|
||||
if (value != null) {
|
||||
node.put(field, epochSeconds(value));
|
||||
node.put(field, EpochSeconds.fromInstant(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user