IFRCGo / go-api

MIT License
14 stars 6 forks source link

Appeal History - Appeal Refactor #2180

Open thenav56 opened 3 months ago

thenav56 commented 3 months ago

Problem Statement

Currently, we have two entities: Appeal and AppealHistory, with the latter used to track changes to Appeal. We have replaced Appeal in all aggregated data and listings where Appeal was originally used. While valid_from and valid_to attributes in AppealHistory allow us to fetch data for specific time periods, these attributes are not utilized within the system itself but only at the endpoint level. This has resulted in a complex structure for endpoints where both Appeal and AppealHistory are needed for calculations, requiring manual definition of valid_from and valid_to attributes.

Some places where it is used https://github.com/IFRCGo/go-api/blob/06f1bc065b43b32b6b57a38dca4e5633e2c6487c/api/drf_views.py#L272-L277

https://github.com/IFRCGo/go-api/blob/06f1bc065b43b32b6b57a38dca4e5633e2c6487c/api/drf_views.py#L807-L814

Proposal

To simplify the structure and usage, we propose the following:

  1. Replace all instances where AppealHistory is used with Appeal.
  2. Create a separate endpoint dedicated to retrieving AppealHistory and treat it as a separate entity.

Related Discussions/PRs

cc: @szabozoltan69 @tovari @batpad @frozenhelium @samshara @udaynwa @susilnem