[WMDE-Fundraising] Add donation transaction log
Closed, ResolvedPublic2 Story Points

Description

The old application has a log field in the data array of donations. The log contains all changes made through the backend (status changed, enabling write, deletions), and some status changes from the frontend: info when the external payment was booked, if the donation was canceled, parent and child IDs of paypal transactions.

While DoctrineDonationRepository::updateDonationEntity will preserve existing logs, there must also be a way to write to the log when one of the cases above occurs.

Internally, the of the log data is an array with timestamps (format `Y-m-d H:i:s') as keys and the log messages as values.

Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptMay 17 2016, 4:48 PM

I don't think we need anything for this in the domain. If all the frontend app is doing is logging events, then having a service that logs such events is enough. The real implementation of that would write to the $data field, though the rest of the app does not need to know about that.

Am I correct in assuming we just need to log events?

We already talked about this a bit in the past, and I suspect it is already tracked to some degree. There is this task about listing all events that need to be logged, which is good to answer before deciding on how to go about it: https://phabricator.wikimedia.org/T132238

Thanks, I must have overlooked T132238. While preparing this task, I've created a crude statistics script that counts the different log entries in the first 50000 donations of 2015. I found out that most of the log-writing is done by the backend application, the frontend only does four different entries. Thus I've created three subtasks for this task. The fourth, the amount of time it took to generate the bank transfer token (Überweisungscode) can be dropped IMHO.

I like the idea of doing it with a service (even when that means bigger constructors) instead of adding a log object to the domain model.

My suggestion for next steps:

  • Close T132238 (Question is answered in this comment).
  • Change description of this task to describe the service instead of modifying the domain object.
  • Close T130111 as duplicate of T135524.
  • Mark T135524 as a blocker for T123046.

If you agree, I will do the steps.

I agree and have done all steps except for changing the description

Some thoughts on the implementation

interface DonationTransactionLogger {
   public function log( Donation $donation, string $message);
}

Question: Internally, $donation will only be needed for getting the ID, but I think the intent is clearer when we use a Donation class instead of just int $donationID, right?

The DoctrineDonationTransactionLogger will try to get the entity, add to the log and write it back.

Any other comments?

@JeroenDeDauw: Should I add a log field to WMDE\Fundraising\Store\DonationData or just use getDecodedData and encodeAndSetData in WMDE\Fundraising\Entities\Donation?

Up to you. I'd be inclined to do the quick thing in the DoctrineLogger, and only add more stuff to the store component when we find ourselves doing that a lot, or are under less time pressure than now.

Lea_WMDE moved this task from Incoming to WMDE Fundraising on the TCB-Team board.Jun 7 2016, 10:45 AM
Tobi_WMDE_SW closed this task as "Resolved".Apr 7 2017, 11:25 AM
Tobi_WMDE_SW claimed this task.
Restricted Application added a project: WMDE-Fun-Team. · View Herald TranscriptApr 7 2017, 11:25 AM