What would we like to use it for?
- Interaction log on the contact page: needs a nice representation of different kinds of interactions and limited filter capabilities (especially on the activity type and date).
- Segmentation of contacts: needs advanced / fast filtering of activities often based on Activity Type specific fields - but usually focussing on a few Activity Types.
- Contact data change-log: needs a way to store differences between two states. This differences don't need to be searchable.
Activities are simply interactions between the organisation and a contact. Generally an activity tells us that a certain kind of interaction (Activity Type) with a contact took place at a certain time, within a specific context and with specific content. What kind of content or context depends heavily on the Activity Type. It's hard to come up with a unified data-structure that can represent all kinds of contents. Our current proposal is to limit the in-table data to two integers (may be foreign-keys) and a text field (which may also contain serialized data).
So we get a data-model close to this:
- id (INT): unique id
- date (INT)
- type (VARCHAR): foreign key for Activity Types
- supporter_id (INT): which contact was involved
- data1 (INT): number, foreign key or integer flag
- data2 (INT): number, foreign key or integer flag
- content (TEXT): text or serialized php-data for additional content that doesn't need filtering but is still useful.
Note that the meaning of data1, data2 and content is only defined per Activity Type.
To get a nice Activity-Type specific layout and advanced filtering we thought of a plugin system that can handle the display of an Activity and also define a views relation so we can access Activity Type specific data.
Should activities be entities?
Currently I'd like to keep things slim/fast and I don't see the benefits of making it activities. But I'd love to be convinced otherwise. ;) Yes. Activity = entity type. Activity Type = bundle.
Specific use-cases and how we would implement them. Feel free to contribute examples!
Campaign with petitons
A campaign that involves signing one of several petitions (webforms having a node_reference to a campaign-node). We want to get a list of all contacts that took action during the campaign.
We would use the fields as follows:
- type = "petition_signed"
- data1 = nid of the petition
- data2 = sid of the webform submission
For the list of contacts we'd make a view with contacts related to activities (filtered by petition_signed) joined to the petition node (filtered by the campaign nid) and group the whole thing by contact. That's it.
What do you think about this?