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

Rethinking the `is_compliance` filter #47

Closed katamartin closed 10 months ago

katamartin commented 10 months ago

It would be useful filter projects down to lists of:

  1. those that are enrolled in compliance programs (currently supported by is_compliance=true
  2. those that are not enrolled in compliance programs (currently not supported?)
  3. either/or (currently supported by omitting is_compliance flag?)

In order to accomplish this, I think we could either rework the behavior of is_compliance so that is_compliance=false and omitting the param do distinct things (2 and 3 above, respectively) or come up with another parameter interface -- open to either!

andersy005 commented 10 months ago

i believe we currently support all three behaviors above

(1) returns those that are enrolled in compliance programs

❯ http 'https://offsets-db-staging.fly.dev/projects/?per_page=1&is_compliance=true'                                                                                       
{
    "data": [
        {
            "category": [
                "industrial-gases"
            ],
            "clips": [],
            "country": "United States",
            "is_compliance": true,
            "issued": 307729,
            "listed_at": null,
            "name": "ECC ODS Destruction 2012",
            "project_id": "ACR170",
            "project_url": "https://acr2.apx.com/mymodule/reg/prjView.asp?id1=170",
            "proponent": "None",
            "protocol": [
                "arb-ozone"
            ],
            "registry": "american-carbon-registry",
            "retired": 0,
            "status": "completed"
        }
    ],
    "pagination": {
        "current_page": 1,
        "next_page": "http://offsets-db-staging.fly.dev/projects/?per_page=1&is_compliance=true&current_page=2",
        "total_entries": 632,
        "total_pages": 632
    }
}

(2): is_compliance=false those that are not enrolled in compliance programs

❯ http 'https://offsets-db-staging.fly.dev/projects/?per_page=1&is_compliance=false'                                                                                      
{
    "data": [
        {
            "category": [
                "renewable-energy"
            ],
            "clips": [],
            "country": "Mali",
            "is_compliance": false,
            "issued": 0,
            "listed_at": null,
            "name": "AFOVERT Energy",
            "project_id": "ACR101",
            "project_url": "https://acr2.apx.com/mymodule/reg/prjView.asp?id1=101",
            "proponent": "None",
            "protocol": [
                "ams-i-e"
            ],
            "registry": "american-carbon-registry",
            "retired": 0,
            "status": "canceled"
        }
    ],
    "pagination": {
        "current_page": 1,
        "next_page": "http://offsets-db-staging.fly.dev/projects/?per_page=1&is_compliance=false&current_page=2",
        "total_entries": 8935,
        "total_pages": 8935
    }
}

(3) returns all projects

❯ http 'https://offsets-db-staging.fly.dev/projects/?per_page=1'                                                                                                          

{
    "data": [
        {
            "category": [
                "renewable-energy"
            ],
            "clips": [],
            "country": "Mali",
            "is_compliance": false,
            "issued": 0,
            "listed_at": null,
            "name": "AFOVERT Energy",
            "project_id": "ACR101",
            "project_url": "https://acr2.apx.com/mymodule/reg/prjView.asp?id1=101",
            "proponent": "None",
            "protocol": [
                "ams-i-e"
            ],
            "registry": "american-carbon-registry",
            "retired": 0,
            "status": "canceled"
        }
    ],
    "pagination": {
        "current_page": 1,
        "next_page": "http://offsets-db-staging.fly.dev/projects/?per_page=1&current_page=2",
        "total_entries": 9567,
        "total_pages": 9567
    }
}
katamartin commented 10 months ago

Sorry for the false flag! Seeing the same thing now with https://github.com/carbonplan/offsets-db-web/commit/ea903ca75dc8a6e4029c89c5f30b2382410e726f