dev add method link
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-05-05 13:44:49 +07:00
parent 6793bbfc5c
commit bb43b6ef4f
8 changed files with 328 additions and 4 deletions
@@ -25,6 +25,8 @@ public interface DockViewRepository extends JpaRepository<DockView, Long> {
Page<DockView> findAllByFileIdOrderByCreatedAtDesc(String fileId, Pageable pageable);
Page<DockView> findAllByFileId(Pageable pageable, List<String> fileId);
Page<DockView> findAllByViewerIdOrderByCreatedAtDesc(Long viewerId, Pageable pageable);
long countByFileId(String fileId);
@@ -59,6 +61,18 @@ public interface DockViewRepository extends JpaRepository<DockView, Long> {
"GROUP BY dv.fileId")
Optional<Object[]> findViewsStatsByFileId(@Param("fileId") String fileId);
@Query("SELECT dv.fileId, " +
"COUNT(dv) as totalViews, " +
"COUNT(DISTINCT dv.viewerIp) as uniqueIps, " +
"COUNT(DISTINCT dv.viewerId) as uniqueUsers, " +
"MAX(dv.createdAt) as lastViewDate, " +
"MIN(dv.createdAt) as firstViewDate " +
"FROM DockView dv " +
"WHERE dv.fileId IN :fileIds " +
"GROUP BY dv.fileId")
List<Object[]> findViewsStatsByFileIds(@Param("fileIds") List<String> fileIds);
void deleteAllByFileId(String fileId);
void deleteAllByCreatedAtBefore(LocalDateTime date);