fix(youtube): fetch the real subscriber total independent of Analytics lag - #150
Closed
murtaja1 wants to merge 1 commit into
Closed
fix(youtube): fetch the real subscriber total independent of Analytics lag#150murtaja1 wants to merge 1 commit into
murtaja1 wants to merge 1 commit into
Conversation
…s lag get_account_metrics only called the Analytics /reports endpoint, so a channel with no activity yet today (Analytics lags 1-2 days and returns empty rows) reported followers=0 instead of its real subscriber count — and any /reports failure lost the total too, since the whole call had nothing else to fall back on. Fetch channels.list?part=statistics first: it's a live point-in-time count independent of date_range, so it stands on its own regardless of what /reports does. A generic Analytics failure now degrades to followers-only (recorded in extra["insight_errors"], matching the other Meta-family providers' insights convention) rather than losing everything; an auth/scope failure still propagates unchanged, since that's what the sync layer's _is_insufficient_scope check relies on to flag the account for reconnect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
get_account_metrics only called the Analytics /reports endpoint, so a channel with no activity yet today (Analytics lags 1-2 days and returns empty rows) reported followers=0 instead of its real subscriber count -- and any /reports failure lost the total too, since the whole call had nothing else to fall back on. Hit this in production on a low-activity channel.
Fix: fetch channels.list?part=statistics first -- it's a live point-in-time count independent of date_range, so it stands on its own regardless of what /reports does. A generic Analytics failure now degrades to followers-only (recorded in extra["insight_errors"], matching the other Meta-family providers' insights convention) rather than losing everything; an auth/scope failure still propagates unchanged, since that's what the sync layer's _is_insufficient_scope check relies on to flag the account for reconnect.
Tested: 6 new unit tests covering followers-from-statistics, an empty Analytics day, a generic Analytics failure, a channel-statistics failure (followers becomes None, Analytics untouched), a scope error still raising, and the channels.list request shape. Full tests/providers/test_youtube.py passes.