diff --git a/app/models.py b/app/models.py index e3242445..b5b8a28e 100644 --- a/app/models.py +++ b/app/models.py @@ -876,7 +876,7 @@ class PostReplyVote(db.Model): class ActivityPubLog(db.Model): id = db.Column(db.Integer, primary_key=True) direction = db.Column(db.String(3)) # 'in' or 'out' - activity_id = db.Column(db.String(100), index=True) + activity_id = db.Column(db.String(256), index=True) activity_type = db.Column(db.String(50)) # e.g. 'Follow', 'Accept', 'Like', etc activity_json = db.Column(db.Text) # the full json of the activity result = db.Column(db.String(10)) # 'success' or 'failure' diff --git a/app/utils.py b/app/utils.py index 94b97d43..9ca9414b 100644 --- a/app/utils.py +++ b/app/utils.py @@ -609,6 +609,10 @@ def _confidence(ups, downs): def confidence(ups, downs) -> float: + if ups is None: + ups = 0 + if downs is None: + downs = 0 if ups + downs == 0: return 0.0 else: diff --git a/migrations/versions/6b4774eb6349_increase_activity_id_length.py b/migrations/versions/6b4774eb6349_increase_activity_id_length.py new file mode 100644 index 00000000..b3ba543d --- /dev/null +++ b/migrations/versions/6b4774eb6349_increase_activity_id_length.py @@ -0,0 +1,38 @@ +"""increase activity id length + +Revision ID: 6b4774eb6349 +Revises: b86c49cbd9a0 +Create Date: 2024-01-19 07:45:25.845475 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '6b4774eb6349' +down_revision = 'b86c49cbd9a0' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('activity_pub_log', schema=None) as batch_op: + batch_op.alter_column('activity_id', + existing_type=sa.VARCHAR(length=100), + type_=sa.String(length=256), + existing_nullable=True) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('activity_pub_log', schema=None) as batch_op: + batch_op.alter_column('activity_id', + existing_type=sa.String(length=256), + type_=sa.VARCHAR(length=100), + existing_nullable=True) + + # ### end Alembic commands ###