How do you compute Cumulative IDs from API response?

This is my best guess from what I can find in the record:

  • iterate over all the IDs & find the last id by the user
  • compare their last taxon.id with the community taxon.id
  • is the observer’s taxon.id in ident_taxon_ids and equal or lower in the ancestry than the community taxon.id? if so, it counts towards the id, so:
    • add 1 to the identifications_count, the right-hand number
    • add 1 to the num_identification_agreements, the left-hand number
  • otherwise it falls into one of two categories:
    • it did not conflict with the community taxon.id (i.e. was one of ident_taxon_ids) but doesn’t count towards the ID (because it was higher in rank than the ID):
      • nothing is added or subtracted
    • it did conflict with the community taxon_id (i.e. was not in ident_taxon_ids), so must be counted as an ID (maverick):
      • add 1 to identifications_count, the right-hand-number

I think everything that is needed for that is in the record, but it seems like an awful lot of extra work, so I just wanted to check if I had missed something simpler.