Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DMP-3392: Include pre-amble/post-amble in job that links cases to audio through events #2647

Merged
merged 9 commits into from
Mar 3, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class AudioConfigurationProperties {
private String tempBlobWorkspace;

private Duration allowableAudioGapDuration;
private Integer preAmbleDuration;
private Integer postAmbleDuration;
private Duration preAmbleDuration;
private Duration postAmbleDuration;
private List<String> handheldAudioCourtroomNumbers;
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public void linkAudioToHearingByEvent(AddAudioMetadataRequest addAudioMetadataRe

String courthouse = addAudioMetadataRequest.getCourthouse();
String courtroom = addAudioMetadataRequest.getCourtroom();
OffsetDateTime start = addAudioMetadataRequest.getStartedAt().minusMinutes(audioConfigurationProperties.getPreAmbleDuration());
OffsetDateTime end = addAudioMetadataRequest.getEndedAt().plusMinutes(audioConfigurationProperties.getPostAmbleDuration());
OffsetDateTime start = addAudioMetadataRequest.getStartedAt().minus(audioConfigurationProperties.getPreAmbleDuration());
OffsetDateTime end = addAudioMetadataRequest.getEndedAt().plus(audioConfigurationProperties.getPostAmbleDuration());
List<EventEntity> courtLogs = courtLogEventRepository.findByCourthouseAndCourtroomBetweenStartAndEnd(
courthouse,
courtroom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ public static class EventProcessor {
private final EventService eventService;
private final MediaLinkedCaseHelper mediaLinkedCaseHelper;


@Getter
@Value("${darts.automated-tasks.pre-amble-duration:0s}")
private final Duration preAmbleDuration;
@Getter
@Value("${darts.automated-tasks.audio-linking.audio-buffer:0s}")
private final Duration audioBuffer;
@Value("${darts.automated-tasks.post-amble-duration:0s}")
private final Duration postAmbleDuration;
private final UserIdentity userIdentity;


Expand All @@ -84,8 +88,8 @@ public void processEvent(Integer eveId) {
EventEntity event = eventService.getEventByEveId(eveId);
List<MediaEntity> mediaEntities = mediaRepository.findAllByMediaTimeContains(
event.getCourtroom().getId(),
event.getTimestamp().plus(getAudioBuffer()),
event.getTimestamp().minus(getAudioBuffer()));
event.getTimestamp().minus(getPreAmbleDuration()),
event.getTimestamp().plus(getPostAmbleDuration()));
mediaEntities.forEach(mediaEntity -> {
mediaLinkedCaseHelper.linkMediaByEvent(event, mediaEntity, MediaLinkedCaseSourceType.AUDIO_LINKING_TASK, userAccount);
});
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ darts:
merge-workspace: ${user.home}/audiotransform/merge
outbounddeleter:
last-accessed-deletion-day: 2
pre-amble-duration: 30
pre-amble-duration: 30m
preview:
redis-ttl-mins: ${AUDIO_PREVIEW_REDIS_TTL:10}
redis-failed-ttl-mins: ${AUDIO_PREVIEW_REDIS_FAILED_TTL:2}
redis-folder: audio-previews
post-amble-duration: 30
post-amble-duration: 30m
re-encode-workspace: ${user.home}/audiotransform/encode
temp-blob-workspace: ${user.home}/audiotransform/tempworkspace
audio-transformation-service:
Expand Down Expand Up @@ -357,7 +357,8 @@ darts:
at-most-for: PT90M
audio-linking:
system-user-email: system_AudioLinking@hmcts.net
audio-buffer: 0s
pre-amble-duration: ${darts.audio.pre-amble-duration}
post-amble-duration: ${darts.audio.post-amble-duration}
lock:
at-least-for: PT1M
at-most-for: PT90M
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ void beforeEach() {
new AudioLinkingAutomatedTask.EventProcessor(
mediaRepository,
eventService, mediaLinkedCaseHelper,
Duration.ofSeconds(0),
Duration.ofSeconds(1),
Duration.ofSeconds(2),
userIdentity)
);
lenient().when(userIdentity.getUserAccount()).thenReturn(userAccount);
Expand Down Expand Up @@ -144,7 +145,9 @@ void processEvent_shouldLinkAudio_whenUsingNoBufferTime() {
verify(mediaLinkedCaseHelper, times(1))
.linkMediaByEvent(event, mediaEntities.get(2), MediaLinkedCaseSourceType.AUDIO_LINKING_TASK, userAccount);
verify(mediaRepository, times(1))
.findAllByMediaTimeContains(123, timestamp, timestamp);
.findAllByMediaTimeContains(123,
timestamp.minus(Duration.ofSeconds(1)),
timestamp.plus(Duration.ofSeconds(2)));
verify(event, times(1))
.setEventStatus(3);

Expand All @@ -158,7 +161,8 @@ void processEvent_shouldLinkAudio_whenUsingNoBufferTime() {
void processEvent_shouldLinkAudio_accountingForBufferTime() {
doNothing().when(mediaLinkedCaseHelper)
.linkMediaByEvent(any(), any(), any(), any());
doReturn(Duration.ofSeconds(10)).when(eventProcessor).getAudioBuffer();
doReturn(Duration.ofSeconds(10)).when(eventProcessor).getPreAmbleDuration();
doReturn(Duration.ofSeconds(20)).when(eventProcessor).getPostAmbleDuration();
EventEntity event = mock(EventEntity.class);
when(eventService.getEventByEveId(2)).thenReturn(event);
OffsetDateTime timestamp = OffsetDateTime.now();
Expand All @@ -181,7 +185,7 @@ void processEvent_shouldLinkAudio_accountingForBufferTime() {
verify(mediaLinkedCaseHelper, times(1))
.linkMediaByEvent(event, mediaEntities.get(2), MediaLinkedCaseSourceType.AUDIO_LINKING_TASK, userAccount);
verify(mediaRepository, times(1))
.findAllByMediaTimeContains(123, timestamp.plusSeconds(10), timestamp.minusSeconds(10));
.findAllByMediaTimeContains(123, timestamp.minus(Duration.ofSeconds(10)), timestamp.plus(Duration.ofSeconds(20)));
verify(event, times(1))
.setEventStatus(3);
verify(eventService, times(1))
Expand Down