Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

log additional information in exchanges #2443

Closed
chadwhitacre opened this issue May 28, 2014 · 12 comments
Closed

log additional information in exchanges #2443

chadwhitacre opened this issue May 28, 2014 · 12 comments

Comments

@chadwhitacre
Copy link
Contributor

When we move money between Gittip and the outside world we call that an "exchange" and we record each such event in the exchanges table. Here's its schema:

=> \d exchanges
                                     Table "public.exchanges"
┌─────────────┬──────────────────────────┬────────────────────────────────────────────────────────┐
│   Column    │           Type           │                       Modifiers                        │
├─────────────┼──────────────────────────┼────────────────────────────────────────────────────────┤
│ id          │ integer                  │ not null default nextval('exchanges_id_seq'::regclass) │
│ timestamp   │ timestamp with time zone │ not null default now()                                 │
│ amount      │ numeric(35,2)            │ not null                                               │
│ fee         │ numeric(35,2)            │ not null                                               │
│ participant │ text                     │ not null                                               │
│ recorder    │ text                     │                                                        │
│ note        │ text                     │                                                        │
└─────────────┴──────────────────────────┴────────────────────────────────────────────────────────┘
Indexes:
    "exchanges_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
    "exchanges_participant_fkey" FOREIGN KEY (participant) REFERENCES participants(username) ON UPDATE CASCADE ON DELETE RESTRICT
    "exchanges_recorder_fkey" FOREIGN KEY (recorder) REFERENCES participants(username) ON UPDATE CASCADE ON DELETE RESTRICT

The relationship between amount and fee is complicated and should be cleaned up. That's #2442.

The recorder and note fields are used when an admin manually enters an exchange.

What we need here is more information recorded during an exchange in order to aid debugging, e.g. on #2372. Exchanges involve API calls to Balanced (etc.). We should record detailed information about what API call was made and what the result was. We should also record what funding instrument was involved so that whether or not there is a failure we can make our reporting more accurate (#1681).

@chadwhitacre
Copy link
Contributor Author

Maybe we use the JSON pg type to store the full result of the API call?

@chadwhitacre
Copy link
Contributor Author

Balanced gives us detailed log info on all API requests, so if we're comfortable trusting Balanced as our datastore then we could simply store the URI on our side.

@chadwhitacre
Copy link
Contributor Author

screen shot 2014-06-17 at 9 27 15 am

@chadwhitacre
Copy link
Contributor Author

screen shot 2014-06-17 at 9 33 03 am
screen shot 2014-06-17 at 9 33 27 am

@chadwhitacre
Copy link
Contributor Author

We at least need to locally store info that we need in order to present receipts and other history to the user.

@chadwhitacre chadwhitacre mentioned this issue Jul 29, 2014
12 tasks
@chadwhitacre
Copy link
Contributor Author

This is blocking #1681.

@Changaco
Copy link
Contributor

Even if we start logging additional information about exchanges it won't fix the past receipts (#1681). If we want to fix those we'll have to do lots of Balanced API queries to retrieve the information.

@chadwhitacre
Copy link
Contributor Author

I think it's worth it to do the extra Balance API queries. It will be a one-time repair and this is fundamental: if we're not trustworthy with financial transactions then what are we worth?

@Changaco
Copy link
Contributor

Added to the Balanced shutdown milestone.

@chadwhitacre
Copy link
Contributor Author

if we're comfortable trusting Balanced as our datastore

😞

@chadwhitacre
Copy link
Contributor Author

If we want to fix those we'll have to do lots of Balanced API queries to retrieve the information.

I downloaded all transactions in JSON format on gratipay/inside.gratipay.com#308 and uploaded them to https://github.com/gratipay/logs/tree/master/misc/308/raw/balanced/transactions.

@chadwhitacre
Copy link
Contributor Author

We should also record what funding instrument was involved so that whether or not there is a failure we can make our reporting more accurate (#1681).

That's the route column, which we have now and need to use properly in #3839, which is blocked on #2779, which is blocked on #3822.

What we need here is more information recorded during an exchange in order to aid debugging, e.g. on #2372. Exchanges involve API calls to Balanced (etc.). We should record detailed information about what API call was made and what the result was.

This is the new ref column that was added in #3810 and should be cleaned up alongside route.

Closing this as done with ref.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants