store fav/reblog count. first step towards #7
This commit is contained in:
parent
79cd7127c5
commit
132007f91f
|
@ -154,6 +154,8 @@ def post_from_api_object(obj, instance):
|
||||||
created_at=obj['created_at'],
|
created_at=obj['created_at'],
|
||||||
author_id=account_from_api_object(obj['account'], instance).id,
|
author_id=account_from_api_object(obj['account'], instance).id,
|
||||||
direct=obj['visibility'] == 'direct',
|
direct=obj['visibility'] == 'direct',
|
||||||
|
favourites=obj['favourites_count'],
|
||||||
|
reblogs=obj['reblogs_count'],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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 ###
|
3
model.py
3
model.py
|
@ -246,6 +246,9 @@ class Post(db.Model, TimestampMixin, RemoteIDMixin):
|
||||||
has_media = db.Column(db.Boolean, server_default='FALSE', nullable=False)
|
has_media = db.Column(db.Boolean, server_default='FALSE', nullable=False)
|
||||||
direct = 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):
|
def __str__(self):
|
||||||
return '<Post ({}, Author: {})>'.format(self.id, self.author_id)
|
return '<Post ({}, Author: {})>'.format(self.id, self.author_id)
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,12 @@
|
||||||
<li>The post's time and date of publishing</li>
|
<li>The post's time and date of publishing</li>
|
||||||
<li>Whether the post has any media attached</li>
|
<li>Whether the post has any media attached</li>
|
||||||
<li>Whether the post has been favourited by you</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>
|
<li>(Mastodon only) Whether the post is a direct message</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>No other post metadata and no post contents are stored by Forget.</p>
|
<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>
|
</section>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue