wose / satnogs-monitor

Terminal UI monitor for your SatNOGS ground station.
GNU General Public License v3.0
78 stars 6 forks source link

check changes in satnogs api pagination #48

Open wose opened 6 months ago

wose commented 6 months ago

See https://community.libre.space/t/satnogs-monitor-not-running-solved/11590

michaelachrisco commented 3 months ago

Im getting the same issue as within the form:

image

Even when the ground station has future observations, the tool will not update.

alitbutt commented 1 month ago

As fredy mentioned here : https://community.libre.space/t/satnogs-monitor-not-running-solved/11590 ; a recent change in pagination technique to use cursors needs a slight change in /satnogs-network-client/src/client.rs

Specifically line 37 : 53 needs to be replaced with this version:

    let mut pages_remaining = true;
    let mut filter_cursor = "".to_owned();
    while pages_remaining {
        pages_remaining = false;
        let mut filter = filter.clone();
        filter.push(("cursor", &filter_cursor));
        match self.client.get_with((), &filter) {
            Ok(resp) => {
                let resp_data: Response<ObservationList> = resp; 
                let resp_headers = resp_data.headers();
                if resp_headers.contains_key("link") {
                    let link_header = &resp_headers["Link"];
                    let res = parse_link_header::parse(link_header.to_str().unwrap());
                    assert!(res.is_ok());

                    let val = res.unwrap();
                    let next_link = val.get(&Some("next".to_string()));
                    if next_link.is_some() {
                        let next_url = &next_link.unwrap();
                        filter_cursor = next_url.queries["cursor"].to_string();
                        pages_remaining = true;
                    }
                }

                let ObservationList::Array(obs) = resp_data.into_inner();
                observations.extend_from_slice(&obs);
            }
            Err(Error::HttpError(404, _)) => break,
            Err(e) => return Err(e),
        }
    }

This code has an added dependency for parse_link_header in satnogs-network-client

I see API requests at some point getting throttled; might have to handle that case separately.