Commit dab37d82 authored by Martin Lowe's avatar Martin Lowe 🇨🇦
Browse files

Change logic to not check contact history for retrieval

parent 1c61c8a5
Pipeline #3000 passed with stage
in 0 seconds
...@@ -60,16 +60,12 @@ public interface PeopleAPI { ...@@ -60,16 +60,12 @@ public interface PeopleAPI {
@QueryParam("project_relation") @QueryParam("project_relation")
public abstract String getRelation(); public abstract String getRelation();
@Nullable
@QueryParam("is_not_expired")
public abstract Boolean getIsNotExpired();
@Nullable @Nullable
@QueryParam("ids") @QueryParam("ids")
public abstract List<String> getIds(); public abstract List<String> getIds();
public static Builder builder() { public static Builder builder() {
return new AutoValue_PeopleAPI_PeopleRequestParams.Builder().setIsNotExpired(false); return new AutoValue_PeopleAPI_PeopleRequestParams.Builder();
} }
@AutoValue.Builder @AutoValue.Builder
...@@ -89,8 +85,6 @@ public interface PeopleAPI { ...@@ -89,8 +85,6 @@ public interface PeopleAPI {
public abstract Builder setIds(@Nullable List<String> ids); public abstract Builder setIds(@Nullable List<String> ids);
public abstract Builder setIsNotExpired(@Nullable Boolean isNotExpired);
public abstract PeopleRequestParams build(); public abstract PeopleRequestParams build();
} }
} }
......
...@@ -250,27 +250,33 @@ public class FoundationDBOrganizationService implements OrganizationsService { ...@@ -250,27 +250,33 @@ public class FoundationDBOrganizationService implements OrganizationsService {
params.add("fName", fName.orElse(null)); params.add("fName", fName.orElse(null));
params.add("lName", lName.orElse(null)); params.add("lName", lName.orElse(null));
return cache.get(orgID, params, OrganizationContactData.class, return cache.get(orgID, params, OrganizationContactData.class,
() -> middleware.getAll(i -> orgAPI.getOrganizationContactsWithSearch(orgID, i, () -> middleware.getAll(
OrganizationRequestParams.builder().setRelation(role.orElse(null)) i -> orgAPI.getOrganizationContactsWithSearch(orgID, i,
.setFirstName(fName.orElse(null)).setLastName(lName.orElse(null)) OrganizationRequestParams.builder().setRelation(role.orElse(null))
.setEmail(mail.orElse(null)).build()), .setFirstName(fName.orElse(null)).setLastName(lName.orElse(null))
.setEmail(mail.orElse(null)).setIsNotExpired(false).build()),
OrganizationContactData.class)); OrganizationContactData.class));
} }
@Override @Override
public Optional<List<OrganizationContactData>> getOrganizationContacts(String orgID, String userName) { public Optional<List<OrganizationContactData>> getOrganizationContacts(String orgID, String userName) {
return cache.get(orgID, new MultivaluedMapImpl<>(), OrganizationContactData.class, () -> middleware.getAll( return cache.get(orgID, new MultivaluedMapImpl<>(), OrganizationContactData.class,
i -> orgAPI.getOrganizationContact(orgID, userName, i, OrganizationRequestParams.builder().build()), () -> middleware.getAll(
OrganizationContactData.class)); i -> orgAPI.getOrganizationContact(orgID, userName, i,
OrganizationRequestParams.builder().setIsNotExpired(false).build()),
OrganizationContactData.class));
} }
@Override @Override
public Optional<List<OrganizationContactData>> getOrganizationContacts(String userName) { public Optional<List<OrganizationContactData>> getOrganizationContacts(String userName) {
return cache.get(userName, new MultivaluedMapImpl<>(), OrganizationContactData.class, return cache
() -> middleware.getAll( .get(userName, new MultivaluedMapImpl<>(), OrganizationContactData.class,
i -> orgAPI.getOrganizationContacts(i, () -> middleware.getAll(
OrganizationRequestParams.builder().setPersonID(userName).build()), i -> orgAPI
OrganizationContactData.class)); .getOrganizationContacts(i,
OrganizationRequestParams.builder().setPersonID(userName)
.setIsNotExpired(false).build()),
OrganizationContactData.class));
} }
@Override @Override
...@@ -278,11 +284,14 @@ public class FoundationDBOrganizationService implements OrganizationsService { ...@@ -278,11 +284,14 @@ public class FoundationDBOrganizationService implements OrganizationsService {
MultivaluedMap<String, String> params = new MultivaluedMapImpl<>(); MultivaluedMap<String, String> params = new MultivaluedMapImpl<>();
params.add(FoundationDBParameterNames.USER_NAME.getName(), userName); params.add(FoundationDBParameterNames.USER_NAME.getName(), userName);
params.add(FoundationDBParameterNames.RELATION.getName(), role); params.add(FoundationDBParameterNames.RELATION.getName(), role);
Optional<List<OrganizationContactData>> contacts = cache.get(orgID, params, OrganizationContactData.class, Optional<List<OrganizationContactData>> contacts = cache
() -> middleware.getAll( .get(orgID, params, OrganizationContactData.class,
i -> orgAPI.getOrganizationContact(orgID, userName, i, () -> middleware.getAll(
OrganizationRequestParams.builder().setRelation(role).build()), i -> orgAPI
OrganizationContactData.class)); .getOrganizationContact(orgID, userName, i,
OrganizationRequestParams.builder().setRelation(role)
.setIsNotExpired(false).build()),
OrganizationContactData.class));
// if we have results, then the relation exists for user // if we have results, then the relation exists for user
return contacts.isPresent() && !contacts.get().isEmpty(); return contacts.isPresent() && !contacts.get().isEmpty();
} }
...@@ -413,7 +422,8 @@ public class FoundationDBOrganizationService implements OrganizationsService { ...@@ -413,7 +422,8 @@ public class FoundationDBOrganizationService implements OrganizationsService {
new URI(info.getCompanyUrl()); new URI(info.getCompanyUrl());
out.setWebsite(info.getCompanyUrl()); out.setWebsite(info.getCompanyUrl());
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
LOGGER.debug("Error while converting URL for organization '{}', leaving blank", info.getOrganizationID(), e); LOGGER.debug("Error while converting URL for organization '{}', leaving blank",
info.getOrganizationID(), e);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment