mirror of
https://github.com/flibusta-apps/telegram_files_cache_server.git
synced 2025-12-06 14:45:36 +01:00
Fix workers count
This commit is contained in:
@@ -29,10 +29,21 @@ def upgrade():
|
|||||||
"object_id", "object_type", name="uc_cached_files_object_id_object_type"
|
"object_id", "object_type", name="uc_cached_files_object_id_object_type"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
op.create_index(
|
||||||
|
op.f("ix_cached_files_object_id"), "cached_files", ["object_id"], unique=False
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
op.f("ix_cached_files_object_type"),
|
||||||
|
"cached_files",
|
||||||
|
["object_type"],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.drop_table("cached_files")
|
op.drop_table("cached_files")
|
||||||
|
op.drop_index("ix_cached_files_object_id")
|
||||||
|
op.drop_index("ix_cached_files_object_type")
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ class CachedFile(ormar.Model):
|
|||||||
constraints = [ormar.UniqueColumns("object_id", "object_type")]
|
constraints = [ormar.UniqueColumns("object_id", "object_type")]
|
||||||
|
|
||||||
id: int = ormar.Integer(primary_key=True) # type: ignore
|
id: int = ormar.Integer(primary_key=True) # type: ignore
|
||||||
object_id: int = ormar.Integer() # type: ignore
|
object_id: int = ormar.Integer(index=True) # type: ignore
|
||||||
object_type: str = ormar.String(max_length=8) # type: ignore
|
object_type: str = ormar.String(max_length=8, index=True) # type: ignore
|
||||||
data: dict = ormar.JSON() # type: ignore
|
data: dict = ormar.JSON() # type: ignore
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ async def get_cached_file(object_id: int, object_type: str):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not cached_file:
|
if not cached_file:
|
||||||
cached_file = await cache_file_by_book_id(object_id, object_type)
|
cached_file = await cache_file_by_book_id({}, object_id, object_type)
|
||||||
|
|
||||||
if not cached_file:
|
if not cached_file:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
||||||
@@ -44,7 +44,7 @@ async def download_cached_file(object_id: int, object_type: str):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not cached_file:
|
if not cached_file:
|
||||||
cached_file = await cache_file_by_book_id(object_id, object_type)
|
cached_file = await cache_file_by_book_id({}, object_id, object_type)
|
||||||
|
|
||||||
if not cached_file:
|
if not cached_file:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|||||||
@@ -24,4 +24,4 @@ class WorkerSettings:
|
|||||||
on_startup = startup
|
on_startup = startup
|
||||||
on_shutdown = shutdown
|
on_shutdown = shutdown
|
||||||
redis_settings = get_redis_settings()
|
redis_settings = get_redis_settings()
|
||||||
max_jobs = 4
|
max_jobs = 2
|
||||||
|
|||||||
Reference in New Issue
Block a user