Skip to content
Snippets Groups Projects

fix: Update caching and logging around Gerrit data

1 file
+ 10
17
Compare changes
  • Side-by-side
  • Inline
@@ -23,7 +23,6 @@ import org.apache.commons.lang3.StringUtils;
import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.eclipsefoundation.core.exception.ApplicationException;
import org.eclipsefoundation.core.helper.TransformationHelper;
import org.eclipsefoundation.core.service.CachingService;
import org.eclipsefoundation.efservices.api.models.EfUser.Email;
import org.eclipsefoundation.efservices.services.DrupalTokenService;
import org.eclipsefoundation.foundationdb.client.model.OrganizationContactData;
@@ -38,8 +37,6 @@ import org.eclipsefoundation.profile.api.OrganizationAPI;
import org.eclipsefoundation.profile.api.PeopleAPI;
import org.eclipsefoundation.profile.api.models.AccountsProfileData;
import org.eclipsefoundation.profile.api.models.GerritChangeData;
import org.eclipsefoundation.profile.namespace.ProfileAPIParameterNames;
import org.jboss.resteasy.specimpl.MultivaluedMapImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,7 +45,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response.Status;
/**
@@ -76,9 +72,6 @@ public class ProfileHelper {
@Inject
DrupalTokenService tokenService;
@Inject
CachingService cache;
@Inject
ObjectMapper objectMapper;
@@ -341,18 +334,18 @@ public class ProfileHelper {
LOGGER.debug("Fetching gerrit changes for user: {}", username);
}
MultivaluedMap<String, String> cacheParams = new MultivaluedMapImpl<>();
cacheParams.add(ProfileAPIParameterNames.CURSOR.getName(), Integer.toString(start));
Optional<List<GerritChangeData>> results = cache
.get(username, cacheParams, GerritChangeData.class, () -> getAllGerritChanges(username, start))
.getData();
if (results.isEmpty() || results.get().isEmpty()) {
LOGGER.warn("Gerrit: No new changes beyond {} for {}", start, username);
try {
return getAllGerritChanges(username, start);
} catch (WebApplicationException e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("GERRIT-API - No results for user: {}", TransformationHelper.formatLog(username), e);
} else {
LOGGER
.warn("GERRIT-API - No results for user: {}, code {}. Enable DEBUG logging for more detailed information",
TransformationHelper.formatLog(username), e.getResponse().getStatus());
}
return Collections.emptyList();
}
return results.get();
}
/**
Loading