Create relative date events on startup

pull/14/head
Sam Bosley 14 years ago
parent 1b2d5c2585
commit bf8dc12ff6

@ -67,4 +67,34 @@ public class ABTestEventDao extends DatabaseDao<ABTestEvent> {
return true; return true;
} }
public void createRelativeDateEvents() {
TodorooCursor<ABTestEvent> allEvents = query(Query.select(ABTestEvent.TEST_NAME, ABTestEvent.DATE_RECORDED)
.where(ABTestEvent.TIME_INTERVAL.eq(ABTestEvent.TIME_INTERVAL_0)));
try {
long now = DateUtilities.now();
for (allEvents.moveToFirst(); !allEvents.isAfterLast(); allEvents.moveToNext()) {
ABTestEvent event = new ABTestEvent(allEvents);
long baseTime = event.getValue(ABTestEvent.DATE_RECORDED);
long timeSinceBase = now - baseTime;
String testName = event.getValue(ABTestEvent.TEST_NAME);
int timeInterval = -1;
if (timeSinceBase > 3 * DateUtilities.ONE_WEEK)
timeInterval = ABTestEvent.TIME_INTERVAL_21;
else if (timeSinceBase > 2 * DateUtilities.ONE_WEEK)
timeInterval = ABTestEvent.TIME_INTERVAL_14;
else if (timeSinceBase > DateUtilities.ONE_WEEK)
timeInterval = ABTestEvent.TIME_INTERVAL_7;
else if (timeSinceBase > 3 * DateUtilities.ONE_DAY)
timeInterval = ABTestEvent.TIME_INTERVAL_3;
if (timeInterval > 0)
createTestEventWithTimeInterval(testName, timeInterval);
}
} finally {
allEvents.close();
}
}
} }

@ -35,6 +35,7 @@ import com.todoroo.astrid.actfm.sync.ActFmSyncService;
import com.todoroo.astrid.backup.BackupConstants; import com.todoroo.astrid.backup.BackupConstants;
import com.todoroo.astrid.backup.BackupService; import com.todoroo.astrid.backup.BackupService;
import com.todoroo.astrid.backup.TasksXmlImporter; import com.todoroo.astrid.backup.TasksXmlImporter;
import com.todoroo.astrid.dao.ABTestEventDao;
import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.gtasks.GtasksPreferenceService; import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.gtasks.sync.GtasksSyncService; import com.todoroo.astrid.gtasks.sync.GtasksSyncService;
@ -91,6 +92,8 @@ public class StartupService {
@Autowired ABTestEventReportingService abTestEventReportingService; @Autowired ABTestEventReportingService abTestEventReportingService;
@Autowired ABTestEventDao abTestEventDao;
/** /**
* bit to prevent multiple initializations * bit to prevent multiple initializations
*/ */
@ -218,8 +221,6 @@ public class StartupService {
initializeABTesting(latestSetVersion == 0); initializeABTesting(latestSetVersion == 0);
AstridPreferences.setPreferenceDefaults(); AstridPreferences.setPreferenceDefaults();
trackABTestingData();
// check for task killers // check for task killers
if(!Constants.OEM) if(!Constants.OEM)
showTaskKillerHelp(context); showTaskKillerHelp(context);
@ -231,28 +232,7 @@ public class StartupService {
abTestEventReportingService.initialize(); abTestEventReportingService.initialize();
abTestEventReportingService.pushAllUnreportedABTestEvents(); abTestEventReportingService.pushAllUnreportedABTestEvents();
abChooser.makeChoicesForAllTests(newUser, taskService.getUserActivationStatus()); abChooser.makeChoicesForAllTests(newUser, taskService.getUserActivationStatus());
} abTestEventDao.createRelativeDateEvents();
private void trackABTestingData() {
long firstLaunchTime = Preferences.getLong(AstridPreferences.P_FIRST_LAUNCH, 0);
long now = DateUtilities.now();
long timeSinceFirst = now - firstLaunchTime;
if (firstLaunchTime == 0) {
// Event days +0
}
if (timeSinceFirst > DateUtilities.ONE_DAY * 3 /*&& !some condition*/) {
// Event days +3
}
if (timeSinceFirst > DateUtilities.ONE_WEEK /*&& !some condition*/) {
// Event days +7
}
if (timeSinceFirst > 2 * DateUtilities.ONE_WEEK /*&& !some condition*/) {
// Event days +14
}
if (timeSinceFirst > 3 * DateUtilities.ONE_WEEK /*&& !some condition*/) {
// Event days +21
}
} }
/** /**

Loading…
Cancel
Save