Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #347 from OpenSRP/issue346
Browse files Browse the repository at this point in the history
Added limits to fetching docs by server version
  • Loading branch information
manutarus authored Nov 21, 2017
2 parents 0adff07 + 93703a0 commit d9ea051
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,9 @@ public void testPushToDHIS2() throws JSONException {
dhis2DatasetPush.openmrsLocationService = this.mockOpenmrsLocationService;
dhis2DatasetPush.config = mockConfig;
dhis2DatasetPush.reportService = mockReportService;

// Test payload is synced with DHIS2
dhis2DatasetPush.pushToDHIS2(event);

verify(dhis2HttpUtils, times(1)).post(anyString(), anyString(), anyString());
verify(mockReportService, times(1)).updateReport(report);
dhis2DatasetPush.pushToDHIS2();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public List<Client> findByEmptyServerVersion() {
public List<Client> findByServerVersion(long serverVersion) {
ComplexKey startKey = ComplexKey.of(serverVersion + 1);
ComplexKey endKey = ComplexKey.of(System.currentTimeMillis());
return db.queryView(createQuery("events_by_version").startKey(startKey).endKey(endKey).includeDocs(true),
return db.queryView(createQuery("events_by_version").startKey(startKey).endKey(endKey).limit(1000).includeDocs(true),
Client.class);
}

Expand All @@ -202,7 +202,7 @@ public List<Client> notInOpenMRSByServerVersion(long serverVersion, Calendar cal
if (serverStartKey < serverEndKey) {
ComplexKey startKey = ComplexKey.of(serverStartKey);
ComplexKey endKey = ComplexKey.of(serverEndKey);
return db.queryView(createQuery("clients_not_in_OpenMRS").startKey(startKey).endKey(endKey).includeDocs(true),
return db.queryView(createQuery("clients_not_in_OpenMRS").startKey(startKey).endKey(endKey).limit(1000).includeDocs(true),
Client.class);
}
return new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void add(CouchDbConnector targetDb, Event event) {
public List<Event> findByServerVersion(long serverVersion) {
ComplexKey startKey = ComplexKey.of(serverVersion + 1);
ComplexKey endKey = ComplexKey.of(Long.MAX_VALUE);
return db.queryView(createQuery("events_by_version").startKey(startKey).endKey(endKey).includeDocs(true),
return db.queryView(createQuery("events_by_version").startKey(startKey).endKey(endKey).limit(1000).includeDocs(true),
Event.class);
}

Expand All @@ -116,7 +116,7 @@ public List<Event> notInOpenMRSByServerVersion(long serverVersion, Calendar cale
if(serverStartKey < serverEndKey) {
ComplexKey startKey = ComplexKey.of(serverStartKey);
ComplexKey endKey = ComplexKey.of(serverEndKey);
return db.queryView(createQuery("events_not_in_OpenMRS").startKey(startKey).endKey(endKey).includeDocs(true), Event.class);
return db.queryView(createQuery("events_not_in_OpenMRS").startKey(startKey).endKey(endKey).limit(1000).includeDocs(true), Event.class);
}
return new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public List<Report> findByEmptyServerVersion() {
public List<Report> findByServerVersion(long serverVersion) {
ComplexKey startKey = ComplexKey.of(serverVersion + 1);
ComplexKey endKey = ComplexKey.of(Long.MAX_VALUE);
return db.queryView(createQuery("reports_by_version").startKey(startKey).endKey(endKey).includeDocs(true),
return db.queryView(createQuery("reports_by_version").startKey(startKey).endKey(endKey).limit(1000).includeDocs(true),
Report.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import java.util.concurrent.locks.ReentrantLock;

import org.joda.time.DateTime;
import org.motechproject.scheduler.domain.MotechEvent;
import org.motechproject.server.event.annotations.MotechListener;
import org.opensrp.common.AllConstants;
import org.opensrp.domain.AppStateToken;
import org.opensrp.domain.Client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void shouldHandleNewEvent() throws Exception {
EventsListener spyEventListener = spy(eventsListener);
when(spyEventListener.getCurrentMilliseconds()).thenReturn(0l);

spyEventListener.processEvent(new MotechEvent("motechEvent"));
spyEventListener.processEvent();


InOrder inOrder = inOrder(allClients, allEvents, eventHandler);
Expand Down

0 comments on commit d9ea051

Please sign in to comment.