Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/main/java/com/redhat/sast/api/config/OshConfiguration.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.redhat.sast.api.config;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.Instant;
import java.time.format.DateTimeParseException;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -264,9 +264,9 @@ public long calculateBackoffMinutes(int attemptNumber) {
* @param attemptNumber attempt number for exponential backoff calculation
* @return cutoff timestamp - only retry scans attempted before this time
*/
public LocalDateTime getRetryCutoffTime(int attemptNumber) {
public Instant getRetryCutoffTime(int attemptNumber) {
long calculatedBackoffMinutes = calculateBackoffMinutes(attemptNumber);
return LocalDateTime.now().minusMinutes(calculatedBackoffMinutes);
return Instant.now().minusSeconds(calculatedBackoffMinutes * 60);
}

/**
Expand All @@ -275,8 +275,8 @@ public LocalDateTime getRetryCutoffTime(int attemptNumber) {
*
* @return cutoff timestamp for basic retry eligibility
*/
public LocalDateTime getStandardRetryCutoffTime() {
return LocalDateTime.now().minus(Duration.parse(retryBackoffDuration));
public Instant getStandardRetryCutoffTime() {
return Instant.now().minus(Duration.parse(retryBackoffDuration));
}

/**
Expand All @@ -285,8 +285,8 @@ public LocalDateTime getStandardRetryCutoffTime() {
*
* @return cutoff timestamp for retention policy
*/
public LocalDateTime getRetentionCutoffTime() {
return LocalDateTime.now().minusDays(retryRetentionDays);
public Instant getRetentionCutoffTime() {
return Instant.now().minusSeconds(retryRetentionDays * 86400L);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/redhat/sast/api/model/DataArtifact.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.redhat.sast.api.model;

import java.time.LocalDateTime;
import java.time.Instant;

import jakarta.persistence.*;
import lombok.Data;
Expand Down Expand Up @@ -37,10 +37,10 @@ public class DataArtifact {
private String metadata;

@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt;
private Instant createdAt;

@PrePersist
public void prePersist() {
this.createdAt = LocalDateTime.now();
this.createdAt = Instant.now();
}
}
18 changes: 9 additions & 9 deletions src/main/java/com/redhat/sast/api/model/Job.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.redhat.sast.api.model;

import java.time.LocalDateTime;
import java.time.Instant;

import com.redhat.sast.api.enums.InputSourceType;
import com.redhat.sast.api.enums.JobStatus;
Expand Down Expand Up @@ -69,22 +69,22 @@ public class Job {
protected JobStatus status;

@Column(name = "created_at", nullable = false)
protected LocalDateTime createdAt;
protected Instant createdAt;

@Column(name = "started_at")
protected LocalDateTime startedAt;
protected Instant startedAt;

@Column(name = "completed_at")
protected LocalDateTime completedAt;
protected Instant completedAt;

@Column(name = "cancelled_at")
protected LocalDateTime cancelledAt;
protected Instant cancelledAt;

@Column(name = "tekton_url")
protected String tektonUrl;

@Column(name = "last_updated_at")
private LocalDateTime lastUpdatedAt;
private Instant lastUpdatedAt;

@Column(name = "submitted_by")
private String submittedBy;
Expand Down Expand Up @@ -113,15 +113,15 @@ public class Job {

@PrePersist
public void prePersist() {
this.createdAt = LocalDateTime.now();
this.lastUpdatedAt = LocalDateTime.now();
this.createdAt = Instant.now();
this.lastUpdatedAt = Instant.now();
if (this.status == null) {
this.status = JobStatus.PENDING;
}
}

@PreUpdate
public void preUpdate() {
this.lastUpdatedAt = LocalDateTime.now();
this.lastUpdatedAt = Instant.now();
}
}
12 changes: 6 additions & 6 deletions src/main/java/com/redhat/sast/api/model/JobBatch.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.redhat.sast.api.model;

import java.time.LocalDateTime;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -30,7 +30,7 @@ public class JobBatch {
private String submittedBy;

@Column(name = "submitted_at", nullable = false)
private LocalDateTime submittedAt;
private Instant submittedAt;

@Enumerated(EnumType.STRING)
@Column(name = "status", nullable = false)
Expand All @@ -46,7 +46,7 @@ public class JobBatch {
private Integer failedJobs;

@Column(name = "last_updated_at")
private LocalDateTime lastUpdatedAt;
private Instant lastUpdatedAt;

@Column(name = "use_known_false_positive_file")
private Boolean useKnownFalsePositiveFile;
Expand All @@ -66,8 +66,8 @@ public class JobBatch {

@PrePersist
public void prePersist() {
this.submittedAt = LocalDateTime.now();
this.lastUpdatedAt = LocalDateTime.now();
this.submittedAt = Instant.now();
this.lastUpdatedAt = Instant.now();
this.status = BatchStatus.PROCESSING;
this.totalJobs = 0;
this.completedJobs = 0;
Expand All @@ -76,7 +76,7 @@ public void prePersist() {

@PreUpdate
public void preUpdate() {
this.lastUpdatedAt = LocalDateTime.now();
this.lastUpdatedAt = Instant.now();
}

public List<Job> getJobs() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/redhat/sast/api/model/JobBatchDataFlow.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.redhat.sast.api.model;

import java.time.LocalDateTime;
import java.time.Instant;
import java.util.List;

import jakarta.persistence.*;
Expand Down Expand Up @@ -30,7 +30,7 @@ public class JobBatchDataFlow {
private String transformationType;

@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt;
private Instant createdAt;

// Shared primary key relationship with JobBatch (1:1)
@OneToOne(fetch = FetchType.LAZY)
Expand All @@ -40,6 +40,6 @@ public class JobBatchDataFlow {

@PrePersist
public void prePersist() {
this.createdAt = LocalDateTime.now();
this.createdAt = Instant.now();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.redhat.sast.api.model;

import java.time.LocalDateTime;
import java.time.Instant;

import jakarta.persistence.*;
import lombok.Data;
Expand Down Expand Up @@ -47,10 +47,10 @@ public class JobBatchRunDefinition {
private String metadata;

@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt;
private Instant createdAt;

@PrePersist
public void prePersist() {
this.createdAt = LocalDateTime.now();
this.createdAt = Instant.now();
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/redhat/sast/api/model/JobMetrics.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.redhat.sast.api.model;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.Instant;

import jakarta.persistence.*;
import lombok.Data;
Expand Down Expand Up @@ -60,7 +60,7 @@ public class JobMetrics {
private String nodeMetrics;

@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt;
private Instant createdAt;

// Shared primary key relationship with Job (1:1)
@OneToOne(fetch = FetchType.LAZY)
Expand All @@ -70,6 +70,6 @@ public class JobMetrics {

@PrePersist
public void prePersist() {
this.createdAt = LocalDateTime.now();
this.createdAt = Instant.now();
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/redhat/sast/api/model/JobTokenUsage.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.redhat.sast.api.model;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.Instant;

import jakarta.persistence.*;
import lombok.Data;
Expand Down Expand Up @@ -36,7 +36,7 @@ public class JobTokenUsage {
private BigDecimal estimatedCost;

@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt;
private Instant createdAt;

// Shared primary key relationship with Job
@OneToOne(fetch = FetchType.LAZY)
Expand All @@ -46,6 +46,6 @@ public class JobTokenUsage {

@PrePersist
public void prePersist() {
this.createdAt = LocalDateTime.now();
this.createdAt = Instant.now();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.redhat.sast.api.model;

import java.time.LocalDateTime;
import java.time.Instant;

import jakarta.persistence.*;
import lombok.Data;
Expand All @@ -21,14 +21,14 @@ public class OshSchedulerCursor {
private String lastSeenToken;

@Column(name = "last_seen_timestamp")
private LocalDateTime lastSeenTimestamp;
private Instant lastSeenTimestamp;

@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
private Instant updatedAt;

@PrePersist
@PreUpdate
public void updateTimestamp() {
this.updatedAt = LocalDateTime.now();
this.updatedAt = Instant.now();
}
}
14 changes: 7 additions & 7 deletions src/main/java/com/redhat/sast/api/model/OshUncollectedScan.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.redhat.sast.api.model;

import java.time.LocalDateTime;
import java.time.Instant;

import com.redhat.sast.api.enums.OshFailureReason;

Expand Down Expand Up @@ -83,14 +83,14 @@ public class OshUncollectedScan {
* Timestamp when this scan was first recorded as uncollected.
*/
@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt;
private Instant createdAt;

/**
* Timestamp of the most recent retry attempt.
* Used for backoff calculations to prevent rapid retry attempts.
*/
@Column(name = "last_attempt_at", nullable = false)
private LocalDateTime lastAttemptAt;
private Instant lastAttemptAt;

/**
* Optimistic locking version field.
Expand Down Expand Up @@ -136,8 +136,8 @@ public OshUncollectedScan(
this.scanDataJson = scanDataJson;
this.lastErrorMessage = errorMessage;
this.attemptCount = 0;
this.createdAt = LocalDateTime.now();
this.lastAttemptAt = LocalDateTime.now();
this.createdAt = Instant.now();
this.lastAttemptAt = Instant.now();
}

/**
Expand All @@ -146,7 +146,7 @@ public OshUncollectedScan(
*/
@PrePersist
public void prePersist() {
LocalDateTime now = LocalDateTime.now();
Instant now = Instant.now();
if (createdAt == null) {
createdAt = now;
}
Expand All @@ -167,7 +167,7 @@ public void prePersist() {
*/
public void recordRetryAttempt(OshFailureReason newFailureReason, String errorMessage) {
this.attemptCount++;
this.lastAttemptAt = LocalDateTime.now();
this.lastAttemptAt = Instant.now();
this.failureReason = newFailureReason;
this.lastErrorMessage = errorMessage;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/redhat/sast/api/model/PricingModel.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.redhat.sast.api.model;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.Instant;

import jakarta.persistence.*;
import lombok.Data;
Expand Down Expand Up @@ -35,15 +35,15 @@ public class PricingModel {
private String currency = "USD";

@Column(name = "effective_from", nullable = false)
private LocalDateTime effectiveFrom;
private Instant effectiveFrom;

@Column(name = "effective_to")
private LocalDateTime effectiveTo;
private Instant effectiveTo;

@PrePersist
public void prePersist() {
if (this.effectiveFrom == null) {
this.effectiveFrom = LocalDateTime.now();
this.effectiveFrom = Instant.now();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.redhat.sast.api.repository;

import java.time.LocalDateTime;
import java.time.Instant;
import java.util.List;

import com.redhat.sast.api.model.DataArtifact;
Expand Down Expand Up @@ -66,7 +66,7 @@ SELECT DISTINCT ON (artifact_type) artifact_id
/**
* Deletes old artifacts (cleanup utility)
*/
public long deleteOlderThan(LocalDateTime cutoffDate) {
public long deleteOlderThan(Instant cutoffDate) {
return delete("createdAt < ?1", cutoffDate);
}
}
Loading