mirror of
https://github.com/Alexander-D-Karpov/akarpov
synced 2025-07-15 00:12:17 +03:00
Lint service code
This commit is contained in:
parent
e1959f7232
commit
7bc8d2da91
|
@ -1,10 +1,11 @@
|
||||||
from sqlalchemy import Boolean, Column, Integer, String, DateTime
|
from sqlalchemy import Boolean, Column, DateTime, Integer, String
|
||||||
|
|
||||||
from redirect.db import Base
|
from redirect.db import Base
|
||||||
|
|
||||||
|
|
||||||
class Link(Base):
|
class Link(Base):
|
||||||
"""Model of a short link that defines slug and target of a redirect."""
|
"""Model of a short link that defines slug and target of a redirect."""
|
||||||
|
|
||||||
__tablename__ = "short_link"
|
__tablename__ = "short_link"
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True, index=True)
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
|
|
|
@ -10,10 +10,10 @@ class AppSettings(BaseSettings):
|
||||||
database_url: str = "postgresql://postgres:postgres@127.0.0.1:5432/akarpov"
|
database_url: str = "postgresql://postgres:postgres@127.0.0.1:5432/akarpov"
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
env_prefix = ''
|
env_prefix = ""
|
||||||
env_file = '.env'
|
env_file = ".env"
|
||||||
env_file_encoding = 'utf-8'
|
env_file_encoding = "utf-8"
|
||||||
extra = 'allow'
|
extra = "allow"
|
||||||
|
|
||||||
|
|
||||||
settings = AppSettings()
|
settings = AppSettings()
|
||||||
|
|
|
@ -10,7 +10,7 @@ def slug_to_link_id(slug: str) -> int:
|
||||||
"""Converts given slug to an id of a link."""
|
"""Converts given slug to an id of a link."""
|
||||||
link_id = 0
|
link_id = 0
|
||||||
try:
|
try:
|
||||||
for i, ch in enumerate(slug[:SLUG_CUTOFF - 1:-1]):
|
for i, ch in enumerate(slug[:SLUG_CUTOFF - 1:-1]): # fmt: skip
|
||||||
value = URL_CHARACTERS.index(ch)
|
value = URL_CHARACTERS.index(ch)
|
||||||
link_id += value * len(URL_CHARACTERS) ** i
|
link_id += value * len(URL_CHARACTERS) ** i
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user