dev add vio
Test Workflow / test (push) Successful in 14s

This commit is contained in:
vladp
2026-03-12 01:32:11 +07:00
parent 869a25043a
commit 65bbb00abf
10 changed files with 321 additions and 6 deletions
@@ -0,0 +1,17 @@
package ru.soune.nocopy.dto.search;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class GlobalSearchStatisticsRequest {
@JsonProperty("token")
private String token;
@JsonProperty("limit")
private Integer limit = 10;
@JsonProperty("days")
private Integer days;
}
@@ -0,0 +1,83 @@
package ru.soune.nocopy.dto.search;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import lombok.Data;
import ru.soune.nocopy.entity.search.GlobalSearchTask;
import java.time.format.DateTimeFormatter;
import java.util.List;
@Data
@Builder
public class GlobalSearchStatisticsResponse {
@JsonProperty("total_searches")
private long totalSearches;
@JsonProperty("searches_by_status")
private StatusCountDto searchesByStatus;
@JsonProperty("recent_searches")
private List<SearchStatDto> recentSearches;
@Data
@Builder
public static class StatusCountDto {
@JsonProperty("processing")
private long processing;
@JsonProperty("completed")
private long completed;
@JsonProperty("failed")
private long failed;
@JsonProperty("total")
private long total;
}
@Data
@Builder
public static class SearchStatDto {
@JsonProperty("task_id")
private String taskId;
@JsonProperty("search_type")
private String searchType;
@JsonProperty("status")
private String status;
@JsonProperty("total_files")
private Integer totalFiles;
@JsonProperty("violations_found")
private long violationsFound;
@JsonProperty("created_at")
private String createdAt;
@JsonProperty("duration_seconds")
private Long durationSeconds;
public static SearchStatDto fromEntity(GlobalSearchTask task, long violationsCount) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
Long duration = null;
if (task.getUpdatedAt() != null && task.getCreatedAt() != null) {
duration = java.time.Duration.between(task.getCreatedAt(), task.getUpdatedAt()).getSeconds();
}
return SearchStatDto.builder()
.taskId(task.getTaskId())
.searchType(task.getSearchType())
.status(task.getStatus())
.totalFiles(task.getTotalFiles())
.violationsFound(violationsCount)
.createdAt(task.getCreatedAt() != null ? task.getCreatedAt().format(formatter) : null)
.durationSeconds(duration)
.build();
}
}
}
@@ -6,8 +6,8 @@ import lombok.Data;
@Data
public class ViolationStatisticsRequest {
@JsonProperty("user_id")
private Long userId;
@JsonProperty("token")
private String token;
@JsonProperty("file_id")
private String fileId;