mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 10:51:36 -04:00
Changing video view_count to bigint for popular videos.
This commit is contained in:
parent
387ef6dfe8
commit
a5dee64af2
3 changed files with 31 additions and 2 deletions
29
alembic/versions/d371333159ab_video_view_count_bigint.py
Normal file
29
alembic/versions/d371333159ab_video_view_count_bigint.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"""Video view_count bigint.
|
||||
|
||||
Revision ID: d371333159ab
|
||||
Revises: b2b9700f5048
|
||||
Create Date: 2026-02-08
|
||||
|
||||
This migration changes the view_count column from INTEGER to BIGINT
|
||||
to accommodate YouTube videos with view counts exceeding 2,147,483,647.
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd371333159ab'
|
||||
down_revision = 'b2b9700f5048'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.alter_column('video', 'view_count',
|
||||
existing_type=sa.Integer(),
|
||||
type_=sa.BigInteger())
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column('video', 'view_count',
|
||||
existing_type=sa.BigInteger(),
|
||||
type_=sa.Integer())
|
||||
|
|
@ -351,7 +351,7 @@ async def update_view_counts_and_censored(channel_id: int):
|
|||
with get_db_curs(commit=True) as curs:
|
||||
# Update the view_count for each video.
|
||||
stmt = '''
|
||||
WITH source AS (select * from json_to_recordset(%s::json) as (id text, view_count int))
|
||||
WITH source AS (select * from json_to_recordset(%s::json) as (id text, view_count bigint))
|
||||
UPDATE video
|
||||
SET view_count = s.view_count
|
||||
FROM source as s
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Video(ModelHelper, Base):
|
|||
id = Column(Integer, primary_key=True)
|
||||
|
||||
source_id = Column(String) # The id from yt-dlp
|
||||
view_count = Column(Integer) # The view count from the ChannelDownloader (or from initial download)
|
||||
view_count = Column(BigInteger) # The view count from the ChannelDownloader (or from initial download)
|
||||
ffprobe_json = deferred(Column(JSONB)) # Data that is fetched once from ffprobe (ffmpeg)
|
||||
have_comments = Column(Boolean, default=False) # see `get_missing_videos_comments`
|
||||
comments_failed = Column(Boolean, default=False) # see `get_missing_videos_comments`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue