Synchronize ab test event reporting to prevent duplicate reports

pull/14/head
Sam Bosley 14 years ago
parent c89de5e952
commit aa12ae6f64

@ -61,15 +61,13 @@ public final class ABTestEventReportingService {
} }
private void pushAllUnreportedABTestEvents() { private void pushAllUnreportedABTestEvents() {
synchronized(ABTestEventReportingService.class) {
if (StatisticsService.dontCollectStatistics()) if (StatisticsService.dontCollectStatistics())
return; return;
final TodorooCursor<ABTestEvent> unreported = abTestEventDao.query(Query.select(ABTestEvent.PROPERTIES) final TodorooCursor<ABTestEvent> unreported = abTestEventDao.query(Query.select(ABTestEvent.PROPERTIES)
.where(ABTestEvent.REPORTED.eq(0)) .where(ABTestEvent.REPORTED.eq(0))
.orderBy(Order.asc(ABTestEvent.TEST_NAME), Order.asc(ABTestEvent.TIME_INTERVAL))); .orderBy(Order.asc(ABTestEvent.TEST_NAME), Order.asc(ABTestEvent.TIME_INTERVAL)));
if (unreported.getCount() > 0) { if (unreported.getCount() > 0) {
new Thread(new Runnable() {
@Override
public void run() {
try { try {
JSONArray payload = jsonArrayFromABTestEvents(unreported); JSONArray payload = jsonArrayFromABTestEvents(unreported);
abTestInvoker.post(payload); abTestInvoker.post(payload);
@ -87,7 +85,6 @@ public final class ABTestEventReportingService {
unreported.close(); unreported.close();
} }
} }
}).start();
} }
} }

Loading…
Cancel
Save