electricitymaps / electricitymaps-contrib

A real-time visualisation of the CO2 emissions of electricity consumption
https://app.electricitymaps.com
GNU Affero General Public License v3.0
3.57k stars 945 forks source link

Fetch exchange capacity from backend #5060

Closed VIKTORVAV99 closed 2 days ago

VIKTORVAV99 commented 1 year ago

We should fetch the exchange capacity from the backend like we do for production capacities, this will allow us to update the capacity and have the change reflected instantly in the mobile apps without having to push new builds.

This will also allow us to remove the capacity information from the generated config files reducing it's size and removing the need to run pnpm generate-zone-config which are currently preventing "web only" edits using GitHubs online interface.

VIKTORVAV99 commented 1 year ago

@madsnedergaard @tonypls did we already resolve this issue?

As far as I can tell we are only importing the exchanges.json file for the exchange arrow data (lonLat and direction). Which means it would be safe to remove the capacity data from the exchanges.json file and get our bundle size and memory use down (we are currently including the capacity in the arrow objects as well).

madsnedergaard commented 1 year ago

Capacity data is not sent through the backend as far as I can tell, so still a TODO :)

# exchanges.json
AU-NSW->AU-QLD":{"capacity":[-1380,880],"lonlat":[146.503,-29.055],"rotation":0}

#app-backend 
"2023-03-26T03:00:00Z": {co2intensity: 449.74, netFlow: -1094.92}
VIKTORVAV99 commented 1 year ago

Capacity data is not sent through the backend as far as I can tell, so still a TODO :)

# exchanges.json
AU-NSW->AU-QLD":{"capacity":[-1380,880],"lonlat":[146.503,-29.055],"rotation":0}

#app-backend 
"2023-03-26T03:00:00Z": {co2intensity: 449.74, netFlow: -1094.92}

But the zone details have this object:

                "exchangeCapacities": {
                    "DE": [
                        -985.0,
                        1000.0
                    ],
                    "DK-DK1": [
                        -600.0,
                        590.0
                    ],
                    "SE-SE4": [
                        -1700.0,
                        1300.0
                    ]
                },

So the backend definitely has the data and it's sent to the frontend, and I can't find any place where we import the exchange capacities in the exchanges.json file except for the arrows and we don't use it there.

VIKTORVAV99 commented 2 days ago

This has been done for a while so closing the issue.