Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CriMDev97 committed Dec 4, 2023
1 parent 3828939 commit f7dc80c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


import it.pagopa.interop.signalhub.updater.cache.model.ConsumerEServiceCache;
import it.pagopa.interop.signalhub.updater.utility.CacheUtils;
import it.pagopa.interop.signalhub.updater.utility.Utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
Expand All @@ -21,12 +21,12 @@ public class ConsumerEServiceCacheRepository {
public void updateConsumerEService(ConsumerEServiceCache item){
Long index = this.findByEservice(item);
if(index != null) {
redisTemplate.opsForList().set(CacheUtils.getCacheKey(item.getEserviceId(), item.getConsumerId()), index, item);
redisTemplate.opsForList().set(Utils.getCacheKey(item.getEserviceId(), item.getConsumerId()), index, item);
log.info("Redis update OrganizationEService: {} ", item.getEserviceId());
}
}

private Long findByEservice(ConsumerEServiceCache consumerEServiceCache) {
return redisTemplate.opsForList().indexOf(CacheUtils.getCacheKey(consumerEServiceCache.getEserviceId(), consumerEServiceCache.getConsumerId()), consumerEServiceCache);
return redisTemplate.opsForList().indexOf(Utils.getCacheKey(consumerEServiceCache.getEserviceId(), consumerEServiceCache.getConsumerId()), consumerEServiceCache);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,20 @@
import it.pagopa.interop.signalhub.updater.model.*;
import it.pagopa.interop.signalhub.updater.service.*;
import it.pagopa.interop.signalhub.updater.utility.Predicates;
import it.pagopa.interop.signalhub.updater.utility.Utils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.stereotype.Component;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;


@Slf4j
@Component
@AllArgsConstructor
public class AutoUpdaterController {
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
private final InteropService interopService;
private final OrganizationService organizationService;
private final ConsumerService consumerService;
Expand All @@ -31,8 +28,7 @@ public class AutoUpdaterController {


public void scheduleUpdater(String applicationType) {
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(Instant.now(), ZoneId.systemDefault());
log.info("ScheduleUpdater of {} started at {}", applicationType, dateTimeFormatter.format(zonedDateTime));
log.info("ScheduleUpdater of {} started at {}", applicationType, Utils.getFormatHour(Instant.now()));
Long lastEventId = this.tracingBatchService.getLastEventIdByTracingBatchAndType(applicationType);
lastEventId = updateRecursiveFlow(lastEventId, applicationType);
tracingBatchService.terminateTracingBatch(TracingBatchStateEnum.ENDED, lastEventId+1, applicationType);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package it.pagopa.interop.signalhub.updater.utility;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class Utils {
private static final String KEY_SEPARATOR= "-";
private static final ZoneId UTC_ZONE = ZoneId.of("UTC");
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");


private Utils() {}

public static String getCacheKey(String eServiceId, String consumerId) {
return eServiceId.concat(KEY_SEPARATOR).concat(consumerId);
}

public static String getFormatHour(Instant instant){
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, UTC_ZONE);
return dateTimeFormatter.format(zonedDateTime);
}
}

0 comments on commit f7dc80c

Please sign in to comment.