2
0
mirror of https://github.com/codl/forget synced 2024-12-25 14:42:41 +01:00

store fav/reblog count. first step towards #7

This commit is contained in:
codl 2017-12-27 20:49:19 +01:00
parent 79cd7127c5
commit 132007f91f
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
5 changed files with 39 additions and 0 deletions

1
.env Normal file
View File

@ -0,0 +1 @@
FLASK_APP=forget.py

View File

@ -154,6 +154,8 @@ def post_from_api_object(obj, instance):
created_at=obj['created_at'],
author_id=account_from_api_object(obj['account'], instance).id,
direct=obj['visibility'] == 'direct',
favourites=obj['favourites_count'],
reblogs=obj['reblogs_count'],
)

View File

@ -0,0 +1,30 @@
"""add favourite, reblog count to posts
Revision ID: 83510ef8c1a5
Revises: c1f7444d0f75
Create Date: 2017-12-27 20:40:31.576201
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '83510ef8c1a5'
down_revision = 'c1f7444d0f75'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('posts', sa.Column('favourites', sa.Integer(), nullable=True))
op.add_column('posts', sa.Column('reblogs', sa.Integer(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('posts', 'reblogs')
op.drop_column('posts', 'favourites')
# ### end Alembic commands ###

View File

@ -246,6 +246,9 @@ class Post(db.Model, TimestampMixin, RemoteIDMixin):
has_media = db.Column(db.Boolean, server_default='FALSE', nullable=False)
direct = db.Column(db.Boolean, server_default='FALSE', nullable=False)
favourites = db.Column(db.Integer)
reblogs = db.Column(db.Integer)
def __str__(self):
return '<Post ({}, Author: {})>'.format(self.id, self.author_id)

View File

@ -13,9 +13,12 @@
<li>The post's time and date of publishing</li>
<li>Whether the post has any media attached</li>
<li>Whether the post has been favourited by you</li>
<li>How many favourites and reblogs / retweets the post has</li>
<li>(Mastodon only) Whether the post is a direct message</li>
</ul>
<p>No other post metadata and no post contents are stored by Forget.</p>
<p>Last updated on 2017-12-27. <a href="https://github.com/codl/forget/commits/templates/privacy.html">History</a>.</p>
</section>
{% endblock %}