aleph-im/pyaleph

Add the modification and creation date in the aggregate messages

Closed this issue · 1 comments

aliel commented

To avoid fetching all the messages to find the creation/modification time of a specific aggregate entry it will be useful to have this info directly in the aggregate message

The solution I suggest is to have a new dictionary in the response of the /api/v0/aggregates endpoint. Currently, the response looks like:

{
  "address": "0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10",
  "data": {
    "key1": ...,
    "key2": ...,
  }
}

We could technically add the information about each key directly in the dictionary of each key but a) there is a risk of conflict with the content of the aggregate and b) users may not want this information most of the time.

I suggest to add a new "info" dictionary at the root level that will contain the information for each key. Example:

{
  "address": "0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10",
  "data": {
    "key1": ...,
    "key2": ...,
  }
  "info": {
    "key1": {
      "created": ...,
      "last_updated": ...,
      "original_item_hash": ...,
      "last_update_item_hash: ...,
    },
    "key2": ...
  }
}

To avoid querying this field by default, I suggest to add a with_info boolean query parameter that defaults to false.