carbonplan / offsets-db-api

accounting of voluntary and compliance offset programs
https://carbonplan.org/research/offsets-db
MIT License
1 stars 0 forks source link

include project category in `/credits` and `/clips` payloads #59

Closed andersy005 closed 12 months ago

andersy005 commented 12 months ago

@katamartin, let's consider two projects, namely A and B. these projects are associated with three categories, which are as follows:

regarding the clips, are we looking to retrieve the following response?


{
...,
"project_ids" ["A", "B"],
"category": ["foo", "zar", "bar"],
...,

}

i'm uncertain whether we need to know the mapping between categories and projects explicitly in /clips payload, or if it is necessary to include the explicit mapping between project_ids and category.

the most recent commit will produce a result that resembles:

   {
      "date": "2022-12-22T00:00:00",
      "title": "In Peru, Kichwa tribe wants compensation for carbon credits",
      "url": "https://apnews.com/article/business-peru-forests-climate-and-environment-2c6cddb1707a12c31c14d9a226699068",
      "source": "AP News",
      "tags": [
        "land-rights",
        "revenue-sharing"
      ],
      "notes": null,
      "is_waybacked": null,
      "type": "press",
      "id": 15,
      "project_ids": [
        "VCS985"
      ],
      "category": [
        "forest"
      ]
    },
    {
      "date": "2023-01-19T00:00:00",
      "title": "Phantom Offsets and Carbon Deceit",
      "url": "https://www.zeit.de/wirtschaft/2023-01/co2-certificates-fraud-emissions-trading-climate-protection-english",
      "source": "ZEIT",
      "tags": [
        "additionality"
      ],
      "notes": null,
      "is_waybacked": null,
      "type": "press",
      "id": 8,
      "project_ids": [
        "VCS994",
        "VCS902"
      ],
      "category": [
        "forest"
      ]
    },
katamartin commented 12 months ago

Ooh good question! We do need to know the explicit project -> category mapping in order to accomplish the following:

CleanShot 2023-11-08 at 09 33 37@2x

It seems like explicitly returning info per project might be a clean/extensible way to do this anyway. This would look something like:

{
"projects": [
  {
    "project_id": "A",
    "category": "foo", "bar"
  },
  {
    "project_id": "b",
    "category": "zar"
  }
}
katamartin commented 11 months ago

On production, it looks like these changes are showing up for /clips but not /credits -- why is that?

andersy005 commented 11 months ago

On production, it looks like these changes are showing up for /clips but not /credits -- why is that?

initially, i didn't find the extended projects field necessary for /credits due to the 1-to-1 mapping between project and credits (a transaction belongs to a single project). therefore, i didn't consider adjusting it when we decided to explicitly map projects and categories for clips (due to the 1-to-many relationship between clips and projects).

andersy005 commented 11 months ago

@katamartin, let me know if it would be convenient to have projects with a single entry for /credits

{
..., 
"projects" : [{"project_id" : "FOO", "category": ["a", "b"]}], 
...
}
katamartin commented 11 months ago

Ahhh right! Even knowing that there's a 1-to-1 relationship between credits and projects, I expected the two endpoints to be formatted similarly. Maybe a single project: {project_id, category} entry could make sense for /credits?