Interface TurLLMTokenUsageRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<TurLLMTokenUsage, String>, org.springframework.data.jpa.repository.JpaRepository<TurLLMTokenUsage, String>, org.springframework.data.repository.ListCrudRepository<TurLLMTokenUsage, String>, org.springframework.data.repository.ListPagingAndSortingRepository<TurLLMTokenUsage, String>, org.springframework.data.repository.PagingAndSortingRepository<TurLLMTokenUsage, String>, org.springframework.data.repository.query.QueryByExampleExecutor<TurLLMTokenUsage>, org.springframework.data.repository.Repository<TurLLMTokenUsage, String>
public interface TurLLMTokenUsageRepository
extends org.springframework.data.jpa.repository.JpaRepository<TurLLMTokenUsage, String>
-
Method Summary
Modifier and TypeMethodDescriptionfindDailyUsage(LocalDateTime start, LocalDateTime end) findMonthlySummary(LocalDateTime start, LocalDateTime end) Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findDailyUsage
@Query("SELECT CAST(u.createdAt AS date) AS day,\n u.turLLMInstance.id AS instanceId,\n u.turLLMInstance.title AS instanceTitle,\n u.vendorId AS vendorId,\n u.modelName AS modelName,\n SUM(u.inputTokens) AS inputTokens,\n SUM(u.outputTokens) AS outputTokens,\n SUM(u.totalTokens) AS totalTokens,\n COUNT(u) AS requestCount\nFROM TurLLMTokenUsage u\nWHERE u.createdAt >= :start AND u.createdAt < :end\nGROUP BY CAST(u.createdAt AS date), u.turLLMInstance.id, u.turLLMInstance.title,\n u.vendorId, u.modelName\nORDER BY day DESC, totalTokens DESC\n") List<Object[]> findDailyUsage(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end) -
findMonthlySummary
@Query("SELECT u.turLLMInstance.id AS instanceId,\n u.turLLMInstance.title AS instanceTitle,\n u.vendorId AS vendorId,\n u.modelName AS modelName,\n SUM(u.inputTokens) AS inputTokens,\n SUM(u.outputTokens) AS outputTokens,\n SUM(u.totalTokens) AS totalTokens,\n COUNT(u) AS requestCount\nFROM TurLLMTokenUsage u\nWHERE u.createdAt >= :start AND u.createdAt < :end\nGROUP BY u.turLLMInstance.id, u.turLLMInstance.title, u.vendorId, u.modelName\nORDER BY totalTokens DESC\n") List<Object[]> findMonthlySummary(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end)
-