Skip to content

Commit

Permalink
21367: Testing updates
Browse files Browse the repository at this point in the history
  • Loading branch information
VSydor committed Aug 29, 2024
1 parent df7f3ee commit 2648b70
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 6 deletions.
17 changes: 13 additions & 4 deletions src/main/java/com/impactupgrade/nucleus/client/SfdcClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,20 @@ protected QueryResult queryDonatingContacts(String updatedSinceClause, String fi
if (!Strings.isNullOrEmpty(filter)) {
filter = " AND " + filter;
}
String opportunitySubQuery = "select ContactId, SUM(amount) from Opportunity " +
String opportunitySubQuery = "(select ContactId from (select ContactId, SUM(amount) from Opportunity " +
"GROUP BY ContactId " +
"HAVING SUM(amount) > 0"; //TODO: can rely on custom field (totalDonationAmount) instead?
String query = "select " + getFieldsList(CONTACT_FIELDS, env.getConfig().salesforce.customQueryFields.contact, extraFields) +
" from Contact where (Id IN" + opportunitySubQuery + ")" + updatedSinceClause + filter;
"HAVING SUM(amount) > 0))"; //TODO: can rely on custom field (totalDonationAmount) instead?
//String query = "select " + getFieldsList(CONTACT_FIELDS, env.getConfig().salesforce.customQueryFields.contact, extraFields) +
String query = "select Id, FirstName, LastName" +
" from Contact where Id IN " + opportunitySubQuery + " AND " + updatedSinceClause + filter;
query = """
select ContactId, SUM(amount) from Opportunity
GROUP BY ContactId
HAVING SUM(amount) > 0
""";
//TODO: join Contact and Opportunity
// then lastUpdatedDate in where
// and sum(amount) in having
return query(query);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Response syncDaily(@QueryParam("syncDays") Integer syncDays, @Context Htt
Runnable thread = () -> {
env.startJobLog(JobType.EVENT, null, "Contacts Sync: Daily", "Nucleus Portal");

SynchronizationService synchronizationService = env.synchronizationService("xero");
SynchronizationService synchronizationService = env.synchronizationService("xeroSync");
try {
synchronizationService.syncContacts(lastSync);
env.logJobInfo("{}: sync unsubscribes done", synchronizationService.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public Response syncDaily(@QueryParam("syncDays") Integer syncDays, @Context Htt
Runnable thread = () -> {
env.startJobLog(JobType.EVENT, null, "Contacts Sync: Daily", "Nucleus Portal");

SynchronizationService synchronizationService = env.synchronizationService("stripe");
SynchronizationService synchronizationService = env.synchronizationService("stripeSync");
try {
synchronizationService.syncContacts(lastSync);
env.logJobInfo("{}: sync unsubscribes done", synchronizationService.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ public PagedResults<CrmContact> getSmsContacts(Calendar updatedSince, Environmen
return new PagedResults<>();
}

@Override
public PagedResults<CrmContact> getDonatingContacts(Calendar updatedSince) throws Exception {
return new PagedResults<>();
}

@Override
public List<CrmUser> getUsers() throws Exception {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ public PagedResults<CrmContact> getSmsContacts(Calendar updatedSince, Environmen
return new PagedResults<>();
}

@Override
public PagedResults<CrmContact> getDonatingContacts(Calendar updatedSince) throws Exception {
return new PagedResults<>();
}

@Override
public double getDonationsTotal(String filter) throws Exception {
throw new RuntimeException("not implemented");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ public PagedResults<CrmContact> getSmsContacts(Calendar updatedSince, Environmen
return new PagedResults<>();
}

@Override
public PagedResults<CrmContact> getDonatingContacts(Calendar updatedSince) throws Exception {
return new PagedResults<>();
}

@Override
public double getDonationsTotal(String filter) throws Exception {
// TODO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ public PagedResults<CrmContact> getSmsContacts(Calendar updatedSince, Environmen
return new PagedResults<>();
}

@Override
public PagedResults<CrmContact> getDonatingContacts(Calendar updatedSince) throws Exception {
return new PagedResults<>();
}

@Override
public List<CrmUser> getUsers() throws Exception {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ public PagedResults<CrmContact> getSmsContacts(Calendar updatedSince, Environmen
return new PagedResults<>();
}

@Override
public PagedResults<CrmContact> getDonatingContacts(Calendar updatedSince) throws Exception {
return new PagedResults<>();
}

@Override
public double getDonationsTotal(String filter) throws Exception {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,11 @@ public PagedResults<CrmContact> getSmsContacts(Calendar updatedSince, Environmen
return PagedResults.unpagedResults(crmContacts);
}

@Override
public PagedResults<CrmContact> getDonatingContacts(Calendar updatedSince) throws Exception {
return new PagedResults<>();
}

@Override
public List<CrmUser> getUsers() throws Exception {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@ public PagedResults<CrmContact> getSmsContacts(Calendar updatedSince, Environmen
return new PagedResults<>();
}

@Override
public PagedResults<CrmContact> getDonatingContacts(Calendar updatedSince) throws Exception {
return new PagedResults<>();
}

@Override
public List<CrmUser> getUsers() throws Exception {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public boolean isConfigured(Environment env) {

@Override
public void init(Environment env) {
this.env = env;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,11 @@ public PagedResults<CrmContact> getSmsContacts(Calendar updatedSince, Environmen
return new PagedResults<>(resultSet);
}

@Override
public PagedResults<CrmContact> getDonatingContacts(Calendar updatedSince) throws Exception {
return new PagedResults<>();
}

@Override
public Map<String, List<String>> getContactCampaignsByContactIds(List<String> contactIds,
EnvironmentConfig.CommunicationList communicationList) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public boolean isConfigured(Environment env) {

@Override
public void init(Environment env) {
this.env = env;
}

// The method can/should be moved to an abstract class
Expand Down

0 comments on commit 2648b70

Please sign in to comment.