Skip to content

Commit 4a3c3a5

Browse files
committed
store url response size in database
1 parent 57d164a commit 4a3c3a5

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""url file size
2+
3+
Revision ID: 86a2d08cfade
4+
Revises: c8d3d789bd34
5+
Create Date: 2022-04-04 04:16:03.267866
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '86a2d08cfade'
14+
down_revision = 'c8d3d789bd34'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.add_column('urls', sa.Column('size', sa.Integer(), nullable=True))
22+
# ### end Alembic commands ###
23+
24+
25+
def downgrade():
26+
# ### commands auto generated by Alembic - please adjust! ###
27+
op.drop_column('urls', 'size')
28+
# ### end Alembic commands ###

placedump/model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def to_dict(self):
5252

5353
url = Column(String, unique=True)
5454
fetched = Column(DateTime, server_default=func.now())
55+
size = Column(Integer)
5556

5657

5758
class Pixel(Base):

placedump/tasks/pixels.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import httpx
99
import numpy as np
10+
import sentry_sdk
1011
from async_timeout import timeout
1112
from b2sdk.exception import TooManyRequests
1213
from gql import gql
@@ -123,6 +124,7 @@ def download_url(board: int, url: str):
123124
insert(URL)
124125
.values(
125126
url=url,
127+
size=len(data),
126128
)
127129
.on_conflict_do_nothing(index_elements=["url"])
128130
)

0 commit comments

Comments
 (0)