Added the ABTestEvent model for tracking events in the database

pull/14/head
Sam Bosley 13 years ago
parent 02049930c9
commit 1f46fa34c6

@ -13,6 +13,7 @@ import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.Property; import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Table; import com.todoroo.andlib.data.Table;
import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.ContextManager;
import com.todoroo.astrid.data.ABTestEvent;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.StoreObject; import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
@ -38,7 +39,7 @@ public class Database extends AbstractDatabase {
* Database version number. This variable must be updated when database * Database version number. This variable must be updated when database
* tables are updated, as it determines whether a database needs updating. * tables are updated, as it determines whether a database needs updating.
*/ */
public static final int VERSION = 23; public static final int VERSION = 24;
/** /**
* Database name (must be unique) * Database name (must be unique)
@ -55,7 +56,8 @@ public class Database extends AbstractDatabase {
StoreObject.TABLE, StoreObject.TABLE,
TagData.TABLE, TagData.TABLE,
Update.TABLE, Update.TABLE,
User.TABLE User.TABLE,
ABTestEvent.TABLE,
}; };
// --- listeners // --- listeners
@ -310,6 +312,12 @@ public class Database extends AbstractDatabase {
Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e); Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e);
} }
case 23: try {
database.execSQL(createTableSql(visitor, ABTestEvent.TABLE.name, ABTestEvent.PROPERTIES));
} catch (SQLiteException e) {
Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e);
}
return true; return true;
} }

@ -0,0 +1,109 @@
package com.todoroo.astrid.data;
import android.content.ContentValues;
import android.net.Uri;
import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Property.IntegerProperty;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.andlib.data.Table;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.api.AstridApiConstants;
@SuppressWarnings("nls")
public class ABTestEvent extends AbstractModel {
public static final long TEST_INTERVAL_0 = 0;
public static final long TEST_INTERVAL_3 = 3 * DateUtilities.ONE_DAY;
public static final long TEST_INTERVAL_7 = DateUtilities.ONE_WEEK;
public static final long TEST_INTERVAL_14 = 2 * DateUtilities.ONE_WEEK;
public static final long TEST_INTERVAL_21 = 3 * DateUtilities.ONE_WEEK;
// --- table and uri
/** table for this model */
public static final Table TABLE = new Table("abtestevent", ABTestEvent.class);
/** content uri for this model */
public static final Uri CONTENT_URI = Uri.parse("content://" + AstridApiConstants.PACKAGE + "/" +
TABLE.name);
// --- properties
/** ID */
public static final LongProperty ID = new LongProperty(
TABLE, ID_PROPERTY_NAME);
/** Name of the test -- one of the constant test keys defined in ABOptions */
public static final StringProperty TEST_NAME = new StringProperty(
TABLE, "testName");
/**
* Which variant (option) was chosen for this user --
* one of the constants in the corresponding descriptions array in ABOptions
*/
public static final StringProperty TEST_VARIANT = new StringProperty(
TABLE, "testVariant");
/**
* Indicates if the user should be considered a new user for the purposes
* of this test.
* Should be 0 if no, 1 if yes
*/
public static final IntegerProperty NEW_USER = new IntegerProperty(
TABLE, "newUser"); // 0 if no, 1 if yes
/**
* Indicates if the user was "activated" at the time of recording this data
* point.
* Should be 0 if no, 1 if yes
* Activated: 3 tasks created, one completed
*/
public static final IntegerProperty ACTIVATED_USER = new IntegerProperty(
TABLE, "activatedUser");
/**
* Which time interval event this data point corresponds to.
* Should be one of the time interval constants defined above.
*/
public static final LongProperty TIME_INTERVAL = new LongProperty(
TABLE, "timeInterval"); // one of the constants defined above
/** The actual date on which this data point was recorded. */
public static final LongProperty DATE_RECORDED = new LongProperty(
TABLE, "dateRecorded");
/** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(Task.class);
private static final ContentValues defaultValues = new ContentValues();
static {
// initialize with default values
}
@Override
public ContentValues getDefaultValues() {
return defaultValues;
}
@Override
public long getId() {
return getIdHelper(ID);
}
// --- parcelable helpers
public static final Creator<ABTestEvent> CREATOR = new ModelCreator<ABTestEvent>(ABTestEvent.class);
@Override
protected Creator<? extends AbstractModel> getCreator() {
return CREATOR;
}
}
Loading…
Cancel
Save