From 54f828b72a59b5537b5da6a7f9a81e9bdd5b3b4b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 19:57:04 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20quality=20distri?= =?UTF-8?q?bution=20query=20in=20channel=20registry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: daggerstuff <261005129+daggerstuff@users.noreply.github.com> --- sourcing/youtube/channel_registry.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/sourcing/youtube/channel_registry.py b/sourcing/youtube/channel_registry.py index 5c291894..e00f2ba4 100644 --- a/sourcing/youtube/channel_registry.py +++ b/sourcing/youtube/channel_registry.py @@ -6,16 +6,15 @@ Uses SQLite for lightweight, embedded database storage. """ +import json import logging import sqlite3 -import json from datetime import datetime from pathlib import Path from typing import Dict, List, Optional from ai.sourcing.youtube.models import ( Channel, - ChannelRegistry, ChannelStatus, ContentCategory, ) @@ -375,18 +374,17 @@ def get_statistics(self) -> Dict: by_status = {row[0]: row[1] for row in cursor.fetchall()} # Quality distribution - cursor.execute( - "SELECT " - " quality_score * 10 AS quality_bucket, " - " COUNT(*) as count " - "FROM channels " - "GROUP BY quality_score * 10 " - "ORDER BY quality_bucket" - ) - quality_dist_raw = cursor.fetchall() + cursor.execute(""" + SELECT + CAST(quality_score * 10 AS INTEGER) AS bucket_id, + COUNT(*) as count + FROM channels + GROUP BY bucket_id + ORDER BY bucket_id + """) quality_dist = { - f"{row[0] / 10:.1f}-{(row[0] + 1) / 10:.1f}": row[1] - for row in quality_dist_raw + f"{row[0] / 10.0:.1f}-{(row[0] + 1) / 10.0:.1f}": row[1] + for row in cursor.fetchall() } # By language