I have a state history table, which contains states of an activity. These states can be repetitive. Sample table :
id activity_name state sub_state
1 firstTask Check INPROGRESS
2 firstTask Check FAIL
3 secondTask Check INPROGRESS
4 secondTask Check SUCCESS
5 seccondTask Initiated INPROGRESS
6 secondTask Initiated SUCCESS
Any new activity with new state can be introduced anytime in the system.
These states in the table are for debugging purpose. Now I need to expose an API which reads this table and convert these states to meaningful states ignoring the repetitions.
Eg, the above table should be exposed as
First TASK:
CHECKED --> FAILED
Second Task:
CHECKED --> INITIATED
What approach/design pattern should I follow which will handle newly introduced states, their compaction and conversion to meaningful state.
Thanks in advance.