]> git.sesse.net Git - skvidarsync/commitdiff
Allow gzip encoding when querying the Sheets API.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 6 Nov 2023 17:32:08 +0000 (18:32 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 6 Nov 2023 17:32:08 +0000 (18:32 +0100)
Doesn't matter all that much (each sheet is 130–150 kB), but is good
as a best practice.

bin/sync.pl

index af7d50e26a14d54d3fa57daa7abcd323e6019855..7f101dc0968793e7c3ee1fa200f839b0b9d14ad1 100644 (file)
@@ -249,7 +249,8 @@ sub get_spreadsheet_with_title {
        # See if we have any spreadsheets that match this title.
        my $start = [Time::HiRes::gettimeofday];
        my $response = $ua->get('https://sheets.googleapis.com/v4/spreadsheets/' . $config::sheet_id . '?key=' . $config::gsheets_api_key . '&fields=sheets/properties',
-               Authorization => 'Bearer ' . $token
+               Authorization => 'Bearer ' . $token,
+               Accept_Encoding => HTTP::Message::decodable
        );
        log_timing($start, '/spreadsheets/properties');
        my $sheets_json = JSON::XS::decode_json($response->decoded_content);
@@ -509,9 +510,11 @@ sub run {
        # Get the list of all people in the sheet (we're going to need them soon anyway).
        my $start = [Time::HiRes::gettimeofday];
        my $response = $ua->get('https://sheets.googleapis.com/v4/spreadsheets/' . $config::sheet_id . '?key=' . $config::gsheets_api_key . '&ranges=' . $tab_name . '!A4:Z5000&fields=sheets/data/rowData/values/userEnteredValue',
-               Authorization => 'Bearer ' . $token
+               Authorization => 'Bearer ' . $token,
+               Accept_Encoding => HTTP::Message::decodable
        );
        log_timing($start, "/spreadsheets/$tab_name");
+
        my $main_sheet_json = JSON::XS::decode_json($response->decoded_content);
 
        # Update the list of groups we've seen people in.
@@ -536,7 +539,8 @@ sub run {
 
        $start = [Time::HiRes::gettimeofday];
        $response = $ua->get('https://sheets.googleapis.com/v4/spreadsheets/' . $config::sheet_id . '?key=' . $config::gsheets_api_key . '&ranges=Slack-mapping!A5:C5000&fields=sheets/data/rowData/values/userEnteredValue',
-               Authorization => 'Bearer ' . $token
+               Authorization => 'Bearer ' . $token,
+               Accept_Encoding => HTTP::Message::decodable
        );
        log_timing($start, "/spreadsheets/Slack-mapping");
        my $mapping_sheet_json = JSON::XS::decode_json($response->decoded_content);