Skip to content

Commit

Permalink
Merge branch 'v2' into ec-indonesia-module
Browse files Browse the repository at this point in the history
  • Loading branch information
James Maina committed Apr 10, 2017
2 parents 44097b3 + 399abc2 commit 106565f
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 56 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Dristhi](opensrp-app/res/drawable-mdpi/login_logo.png)] (https://smartregister.atlassian.net/wiki/dashboard.action)
[![Dristhi](opensrp-app/res/drawable-mdpi/login_logo.png)](https://smartregister.atlassian.net/wiki/dashboard.action)

To run this project, you need to do this:
========================================
Expand Down
117 changes: 84 additions & 33 deletions docs/apk-download.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,40 +216,92 @@ <h3>Indonesia Apks</h3>
</div>
<div id="thr_pk" class="tab-pane fade">
<div>
<h3>OpenSRP Immunization app</h3>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>ID</th>
<th>QR Code</th>
<th>Components</th>
</tr>
</thead>
<tbody>
<tr>
<td>Immunization</td>
<td><a href="https://docs.google.com/uc?export=download&id=0BzS8x1-rizzKVTlLOGlaOXQzbTQ">opensrp-immunization-4.1.1b</a></td>
<td><a rel='nofollow' href='http://www.qrcode-generator.de' border='0' style='cursor:default'></a><img src='https://chart.googleapis.com/chart?cht=qr&chl=https://docs.google.com/uc?export=download&id=0BzS8x1-rizzKVTlLOGlaOXQzbTQ&chs=180x180&choe=UTF-8&chld=L|2' alt=''></td>
<td> <ul>
<li>Household Register
<li>Woman Register
<li>Child Register
<li>Stock Register
<li>Reporting [Woman, Child]
<li>Provider Profile
<li>Release Notes [TBD]
</ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3>OpenSRP Immunization app</h3>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>ID</th>
<th>QR Code</th>
<th>Components</th>
</tr>
</thead>
<tbody>
<tr>
<td>Immunization</td>
<td><a href="https://docs.google.com/uc?export=download&id=0BzS8x1-rizzKVTlLOGlaOXQzbTQ">opensrp-immunization-4.1.1b</a></td>
<td><a rel='nofollow' href='http://www.qrcode-generator.de' border='0' style='cursor:default'></a><img src='https://chart.googleapis.com/chart?cht=qr&chl=https://docs.google.com/uc?export=download&id=0BzS8x1-rizzKVTlLOGlaOXQzbTQ&chs=180x180&choe=UTF-8&chld=L|2' alt=''></td>
<td>
<ul>
<li>Household Register
<li>Woman Register
<li>Child Register
<li>Stock Register
<li>Reporting [Woman, Child]
<li>Provider Profile
<li>Release Notes [TBD]
</ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="bid_zm" class="tab-pane fade">
<!-- Add Zambia Apks -->
<h3>Path Apk</h3>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>QR Code</th>
<th>Link</th>
</tr>
</thead>
<tbody>
<tr>
<td>opensrp-path-release-1.1.1 built_on_07-04-17 (advanced search, adverse event, weight notification, march release fixes)</td>
<td><a rel='nofollow' href='http://www.qrcode-generator.de' border='0' style='cursor:default'><img src='https://chart.googleapis.com/chart?cht=qr&chl=https%3A%2F%2Fdrive.google.com%2Fuc%3Fexport%3Ddownload%26id%3D0BwkteZyRzaQOUGFweHFjLXZLZHc&chs=180x180&choe=UTF-8&chld=L|2' alt=''></a></td>
<td><a href="https://drive.google.com/uc?export=download&id=0BwkteZyRzaQOUGFweHFjLXZLZHc">https://drive.google.com/uc?export=download&id=0BwkteZyRzaQOUGFweHFjLXZLZHc</a></td>

</tr>
<tr>
<td>opensrp-path-release-1.1.0 built_on_31-03-17 (out of catchment form, due/overdue/ sync alerts/ edit demographics/ march release fixes)</td>
<td><a rel='nofollow' href='http://www.qrcode-generator.de' border='0' style='cursor:default'></a><img src='https://chart.googleapis.com/chart?cht=qr&chl=https%3A%2F%2Fdrive.google.com%2Fuc%3Fexport%3Ddownload%26id%3D0B1A3BnI7x8VOLVRRc3lHQV81S2M&chs=180x180&choe=UTF-8&chld=L|2' alt=''></td>
<td><a href="https://drive.google.com/uc?export=download&id=0B1A3BnI7x8VOLVRRc3lHQV81S2M">https://drive.google.com/uc?export=download&id=0B1A3BnI7x8VOLVRRc3lHQV81S2M</a></td>

</tr>
<tr>
<td>opensrp-path-release built_on_27-03-17 (out of catchment form, due/overdue/ sync alerts)</td>
<td><a rel='nofollow' href='http://www.qrcode-generator.de' border='0' style='cursor:default'></a><img src='https://chart.googleapis.com/chart?cht=qr&chl=https%3A%2F%2Fdrive.google.com%2Fuc%3Fexport%3Ddownload%26id%3D0B5d95GNPTOy1dGVXSHNyNE9CUUE&chs=180x180&choe=UTF-8&chld=L|2' alt=''></td>
<td><a href="https://drive.google.com/uc?export=download&id=0B5d95GNPTOy1dGVXSHNyNE9CUUE">https://drive.google.com/uc?export=download&id=0B5d95GNPTOy1dGVXSHNyNE9CUUE</a></td>
</tr>
<tr>
<td>opensrp-path-release built_on_15-03-17 (saving vaccines/weights)</td>
<td><a rel='nofollow' href='http://www.qrcode-generator.de' border='0' style='cursor:default'></a><img src='https://chart.googleapis.com/chart?cht=qr&chl=https%3A%2F%2Fdrive.google.com%2Fuc%3Fexport%3Ddownload%26id%3D0B3F9Fte7ey_wRXdvV3BTUmpSTWc&chs=180x180&choe=UTF-8&chld=L|2' alt=''></td>
<td><a href="https://drive.google.com/uc?export=download&id=0B3F9Fte7ey_wRXdvV3BTUmpSTWc">https://drive.google.com/uc?export=download&id=0B3F9Fte7ey_wRXdvV3BTUmpSTWc</a></td>
</tr>
<tr>
<td>opensrp-path-release built_on_03-03-17 (qr code working)</td>
<td><a rel='nofollow' href='http://www.qrcode-generator.de' border='0' style='cursor:default'><img src='https://chart.googleapis.com/chart?cht=qr&chl=https%3A%2F%2Fdrive.google.com%2Fuc%3Fexport%3Ddownload%26id%3D0BwkteZyRzaQOVXdscjZEV1ZOOEU&chs=180x180&choe=UTF-8&chld=L|2' alt=''></a></td>
<td><a href="https://drive.google.com/uc?export=download&id=0BwkteZyRzaQOVXdscjZEV1ZOOEU">https://drive.google.com/uc?export=download&id=0BwkteZyRzaQOVXdscjZEV1ZOOEU</a></td>
</tr>
<tr>
<td>opensrp-path-release built_on_02-03-17</td>
<td><a rel='nofollow' href='http://www.qrcode-generator.de' border='0' style='cursor:default'><img src='https://chart.googleapis.com/chart?cht=qr&chl=https%3A%2F%2Fdrive.google.com%2Fuc%3Fexport%3Ddownload%26id%3D0BwkteZyRzaQOcmZaOXI5VHU0OU0&chs=180x180&choe=UTF-8&chld=L|2' alt=''></a></td>
<td><a href="https://drive.google.com/uc?export=download&id=0BwkteZyRzaQOcmZaOXI5VHU0OU0">https://drive.google.com/uc?export=download&id=0BwkteZyRzaQOcmZaOXI5VHU0OU0</a></td>
</tr>
<tr>
<td>archive path-release built_on_28-02-17</td>
<td><a rel='nofollow' href='http://www.qrcode-generator.de' border='0' style='cursor:default'><img src='https://chart.googleapis.com/chart?cht=qr&chl=https%3A%2F%2Fdrive.google.com%2Fuc%3Fexport%3Ddownload%26id%3D0BwkteZyRzaQOUVhSeXVGclhQbjQ&chs=180x180&choe=UTF-8&chld=L|2' alt=''></a></td>
<td><a href="https://drive.google.com/uc?export=download&id=0BwkteZyRzaQOUVhSeXVGclhQbjQ">https://drive.google.com/uc?export=download&id=0BwkteZyRzaQOUVhSeXVGclhQbjQ</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
Expand All @@ -268,5 +320,4 @@ <h3>OpenSRP Immunization app</h3>
</div>
</div>
</body>
</html>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class FormDataRepositoryTest extends AndroidTestCase {
private FormDataRepository repository;
private EligibleCoupleRepository eligibleCoupleRepository;
private MotherRepository motherRepository;
private int MAX_SIZE = 50;

@Override
protected void setUp() throws Exception {
Expand Down Expand Up @@ -198,7 +199,7 @@ public void testShouldFetchPendingFormSubmissions() throws Exception {
repository.saveFormSubmission(secondSubmission);
repository.saveFormSubmission(thirdSubmission);

List<FormSubmission> pendingFormSubmissions = repository.getPendingFormSubmissions();
List<FormSubmission> pendingFormSubmissions = repository.getPendingFormSubmissions(MAX_SIZE);

assertEquals(asList(firstSubmission, secondSubmission), pendingFormSubmissions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ public FormSubmission fetchFromSubmission(String instanceId) {
return readFormSubmission(cursor).get(0);
}

public List<FormSubmission> getPendingFormSubmissions() {
public List<FormSubmission> getPendingFormSubmissions(int maxSize) {
SQLiteDatabase database = masterRepository.getReadableDatabase();
Cursor cursor = database.query(FORM_SUBMISSION_TABLE_NAME, FORM_SUBMISSION_TABLE_COLUMNS, SYNC_STATUS_COLUMN + " = ?", new String[]{PENDING.value()}, null, null, null);
Cursor cursor = database.query(FORM_SUBMISSION_TABLE_NAME, FORM_SUBMISSION_TABLE_COLUMNS, SYNC_STATUS_COLUMN + " = ?", new String[]{PENDING.value()}, null, null, null, ""+maxSize);
return readFormSubmission(cursor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class FormSubmissionSyncService {
private AllSharedPreferences allSharedPreferences;
private FormSubmissionService formSubmissionService;
private DristhiConfiguration configuration;
private final int MAX_SIZE = 50;

public FormSubmissionSyncService(FormSubmissionService formSubmissionService, HTTPAgent httpAgent,
FormDataRepository formDataRepository, AllSettings allSettings,
Expand Down Expand Up @@ -69,22 +70,29 @@ public FetchStatus sync() {
}

public void pushToServer() {
List<FormSubmission> pendingFormSubmissions = formDataRepository.getPendingFormSubmissions();
if (pendingFormSubmissions.isEmpty()) {
return;
}
String jsonPayload = mapToFormSubmissionDTO(pendingFormSubmissions);
Response<String> response = httpAgent.post(
format("{0}/{1}",
configuration.dristhiBaseURL(),
FORM_SUBMISSIONS_PATH),
jsonPayload);
if (response.isFailure()) {
logError(format("Form submissions sync failed. Submissions: {0}", pendingFormSubmissions));
return;
boolean keepSyncing = true;
while (keepSyncing) {
List<FormSubmission> pendingFormSubmissions = formDataRepository.getPendingFormSubmissions(MAX_SIZE);
if (pendingFormSubmissions.isEmpty()) {
return;
}

if(pendingFormSubmissions.size() < 50){
keepSyncing = false;
}
String jsonPayload = mapToFormSubmissionDTO(pendingFormSubmissions);
Response<String> response = httpAgent.post(
format("{0}/{1}",
configuration.dristhiBaseURL(),
FORM_SUBMISSIONS_PATH),
jsonPayload);
if (response.isFailure()) {
logError(format("Form submissions sync failed. Submissions: {0}", pendingFormSubmissions));
return;
}
formDataRepository.markFormSubmissionsAsSynced(pendingFormSubmissions);
logInfo(format("Form submissions sync successfully. Submissions: {0}", pendingFormSubmissions));
}
formDataRepository.markFormSubmissionsAsSynced(pendingFormSubmissions);
logInfo(format("Form submissions sync successfully. Submissions: {0}", pendingFormSubmissions));
}

public FetchStatus pullFromServer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

@RunWith(RobolectricTestRunner.class)
public class FormSubmissionSyncServiceTest {
private int MAX_SIZE = 50;
@Mock
private FormDataRepository repository;
@Mock
Expand Down Expand Up @@ -61,7 +62,7 @@ public void setUp() throws Exception {
"anm id 1", "id 1", "entity id 1", "form name", formInstanceJSON, "123", "1"));
when(configuration.dristhiBaseURL()).thenReturn("http://dristhi_base_url");
when(allSharedPreferences.fetchRegisteredANM()).thenReturn("anm id 1");
when(repository.getPendingFormSubmissions()).thenReturn(submissions);
when(repository.getPendingFormSubmissions(MAX_SIZE)).thenReturn(submissions);
}

@Test
Expand All @@ -84,17 +85,17 @@ public void shouldNotMarkPendingSubmissionsAsSyncedIfPostFails() throws Exceptio

service.pushToServer();

verify(repository).getPendingFormSubmissions();
verify(repository).getPendingFormSubmissions(MAX_SIZE);
verifyNoMoreInteractions(repository);
}

@Test
public void shouldNotPushIfThereAreNoPendingSubmissions() throws Exception {
when(repository.getPendingFormSubmissions()).thenReturn(Collections.<FormSubmission>emptyList());
when(repository.getPendingFormSubmissions(MAX_SIZE)).thenReturn(Collections.<FormSubmission>emptyList());

service.pushToServer();

verify(repository).getPendingFormSubmissions();
verify(repository).getPendingFormSubmissions(MAX_SIZE);
verifyNoMoreInteractions(repository);
verifyZeroInteractions(allSettings);
verifyZeroInteractions(httpAgent);
Expand Down

0 comments on commit 106565f

Please sign in to comment.