Skip to content

Commit

Permalink
Merge pull request #17 from FINTLabs/FFS-1182-finne-ut-hvorfor-det-ta…
Browse files Browse the repository at this point in the history
…r-veldig-lang-tid-a-hente-ut-events-fra-history-service

Ffs 1182 finne ut hvorfor det tar veldig lang tid a hente ut events fra history service
  • Loading branch information
Battlestad authored Sep 2, 2024
2 parents e925158 + bfe62aa commit e265788
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion kustomize/base/flais.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
- name: fint.flyt.resource-server.security.api.internal.enabled
value: "true"
- name: fint.flyt.resource-server.user-permissions-consumer.enabled
value: "false"
value: "true"
resources:
limits:
memory: "2048Mi"
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/no/fintlabs/repositories/EventRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,18 @@ Page<Event> findAllByInstanceFlowHeadersSourceApplicationIdAndInstanceFlowHeader
)
Page<Event> findLatestEventPerSourceApplicationInstanceId(Pageable pageable);

@Query(value = "SELECT e FROM Event e " +
"WHERE e.instanceFlowHeaders.sourceApplicationId IN :sourceApplicationIds " +
"AND e.timestamp = (SELECT MAX(e2.timestamp) " +
"FROM Event e2 " +
"WHERE e2.instanceFlowHeaders.sourceApplicationInstanceId = e.instanceFlowHeaders.sourceApplicationInstanceId " +
"AND e2.instanceFlowHeaders.sourceApplicationId IN :sourceApplicationIds) ")
@Query(value = "SELECT e.* " +
"FROM event AS e " +
"INNER JOIN ( " +
" SELECT source_application_instance_id, MAX(timestamp) AS timestampMax " +
" FROM event " +
" WHERE source_application_id IN :sourceApplicationIds " +
" GROUP BY source_application_instance_id " +
") AS eMax " +
"ON e.source_application_instance_id = eMax.source_application_instance_id " +
"AND e.timestamp = eMax.timestampMax " +
"WHERE e.source_application_id IN :sourceApplicationIds",
nativeQuery = true)
Page<Event> findLatestEventPerSourceApplicationInstanceIdAndSourceApplicationIdIn(
@Param("sourceApplicationIds") List<Long> sourceApplicationIds,
Pageable pageable);
Expand Down

0 comments on commit e265788

Please sign in to comment.