"""The Stats page's "Full history: done / requested" ratio counts the SAME channels on both sides — the ones this user asked full history for. The numerator used to count every subscribed channel whose back-catalog was complete (another user had asked, or the channel was short), so the page read "342/329". "Channels without full history yet" still counts every subscribed channel. Needs the DB.""" from app.models import Channel, Subscription def test_full_history_ratio_counts_only_the_requested_channels(db, make_user, as_user): user = make_user("deep@example.com") db.add_all( [ Channel(id="UCreqdone", title="Requested, done", backfill_done=True), Channel(id="UCreqopen", title="Requested, pending", backfill_done=False), Channel(id="UCdone", title="Not requested, done anyway", backfill_done=True), Channel(id="UCopen", title="Not requested, pending", backfill_done=False), ] ) db.flush() db.add_all( [ Subscription(user_id=user.id, channel_id="UCreqdone", deep_requested=True), Subscription(user_id=user.id, channel_id="UCreqopen", deep_requested=True), Subscription(user_id=user.id, channel_id="UCdone"), Subscription(user_id=user.id, channel_id="UCopen"), ] ) db.commit() body = as_user(user).get("/api/sync/my-status").json() assert body["channels_deep_requested"] == 2 assert body["channels_deep_done"] == 1 # never more than it is out of assert body["channels_deep_pending"] == 2 # subscribed channels without full history yet