Page MenuHomePhabricator

Add functionality to save contributions to the database
Closed, ResolvedPublic

Description

We store each individual edit made by the user as a row in the Contributions table. If the user makes multiple changes before they click save, we will internally process it as a series of individual commits to the database.

For example, if the user does the following:

  • Remove 1 existing depicts item
  • Add 2 new depicts items
  • Click save

Then we would actually add 3 new entries to the database (one for each individual statement added/removed)

Data structure

These are the columns to use, along with some example data

iduser_idcampaign_idfileedit_typeedit_actionedit_content
173File:Blackcat-Lilith.jpg"depicts""add""Q123"
223File:Blackcat-Lilith.jpg"depicts""remove""Q123"
273File:Blackcat-Lilith.jpg"caption""add""en: A black cat"
273File:Blackcat-Lilith.jpg"caption""edit""fr: Un chat noir"

user_id and campaign_id

Both foreign keys pointing to their respective tables.

file

Common's filename which has been edited

edit_type

"depicts" or "caption".

edit_action

"add", "remove", or "edit"
Note: "edit" only applicable for caption edits

edit_content

String which is either a Q number (for depicts - e.g. "Q84"), or language prefixed text (for captions - e.g. "en: some caption")

Event Timeline

@Eugene233 I've edited the description now with a bit more info on the suggested structure. Please do come back with any suggestions.

The other option I feel is worth considering is to only have a single edit for each row.
So, for example if the user does the following:

  • Remove 1 existing depicts item
  • Add 2 new depicts items
  • Click save

Then we would actually add 3 new entries to the database (one for each individual statement added/removed)
If we do that then the actual data we store can be much simpler and more efficient to query, with a structure something like this:

iduser_idcampaign_idfileedit_typeedit_actionedit_content
1"Eugene233"3File:Blackcat-Lilith.jpg"depicts""add""Q123"
2"NavinoEvans"3File:Blackcat-Lilith.jpg"depicts""remove""Q123"
2"Eugene233"3File:Blackcat-Lilith.jpg"caption""add""en: A black cat"
2"Eugene233"3File:Blackcat-Lilith.jpg"caption""edit""fr: Un chat noir"

I've edited the description now with a bit more info on the suggested structure. Please do come back with any suggestions.

This looks great. However, I think it constraints us to validate just a depict or caption at a time. Alternatively, we can collect all the depicts and then create a contribution for each...

Description updated after deciding to go with the simpler 1 edit per row structure

Change 510118 had a related patch set uploaded (by Eugene233; owner: Eugene233):
[labs/tools/Isa@master] Add functionality to save contributions to the database

https://gerrit.wikimedia.org/r/510118

Change 510118 merged by jenkins-bot:
[labs/tools/Isa@master] Add functionality to save contributions to the database

https://gerrit.wikimedia.org/r/510118

Marking as resolved.