chore(lint): make ruff happy
This commit is contained in:
@@ -1,40 +1,59 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
User Login Log Database Model
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from sqlmodel import Field, SQLModel
|
||||
|
||||
|
||||
class UserLoginLog(SQLModel, table=True):
|
||||
"""User login log table"""
|
||||
|
||||
__tablename__ = "user_login_log" # pyright: ignore[reportAssignmentType]
|
||||
|
||||
id: Optional[int] = Field(default=None, primary_key=True, description="Record ID")
|
||||
id: int | None = Field(default=None, primary_key=True, description="Record ID")
|
||||
user_id: int = Field(index=True, description="User ID")
|
||||
ip_address: str = Field(max_length=45, index=True, description="IP address (supports IPv4 and IPv6)")
|
||||
user_agent: Optional[str] = Field(default=None, max_length=500, description="User agent information")
|
||||
login_time: datetime = Field(default_factory=datetime.utcnow, description="Login time")
|
||||
|
||||
ip_address: str = Field(
|
||||
max_length=45, index=True, description="IP address (supports IPv4 and IPv6)"
|
||||
)
|
||||
user_agent: str | None = Field(
|
||||
default=None, max_length=500, description="User agent information"
|
||||
)
|
||||
login_time: datetime = Field(
|
||||
default_factory=datetime.utcnow, description="Login time"
|
||||
)
|
||||
|
||||
# GeoIP information
|
||||
country_code: Optional[str] = Field(default=None, max_length=2, description="Country code")
|
||||
country_name: Optional[str] = Field(default=None, max_length=100, description="Country name")
|
||||
city_name: Optional[str] = Field(default=None, max_length=100, description="City name")
|
||||
latitude: Optional[str] = Field(default=None, max_length=20, description="Latitude")
|
||||
longitude: Optional[str] = Field(default=None, max_length=20, description="Longitude")
|
||||
time_zone: Optional[str] = Field(default=None, max_length=50, description="Time zone")
|
||||
|
||||
country_code: str | None = Field(
|
||||
default=None, max_length=2, description="Country code"
|
||||
)
|
||||
country_name: str | None = Field(
|
||||
default=None, max_length=100, description="Country name"
|
||||
)
|
||||
city_name: str | None = Field(default=None, max_length=100, description="City name")
|
||||
latitude: str | None = Field(default=None, max_length=20, description="Latitude")
|
||||
longitude: str | None = Field(default=None, max_length=20, description="Longitude")
|
||||
time_zone: str | None = Field(default=None, max_length=50, description="Time zone")
|
||||
|
||||
# ASN information
|
||||
asn: Optional[int] = Field(default=None, description="Autonomous System Number")
|
||||
organization: Optional[str] = Field(default=None, max_length=200, description="Organization name")
|
||||
|
||||
asn: int | None = Field(default=None, description="Autonomous System Number")
|
||||
organization: str | None = Field(
|
||||
default=None, max_length=200, description="Organization name"
|
||||
)
|
||||
|
||||
# Login status
|
||||
login_success: bool = Field(default=True, description="Whether the login was successful")
|
||||
login_method: str = Field(max_length=50, description="Login method (password/oauth/etc.)")
|
||||
|
||||
login_success: bool = Field(
|
||||
default=True, description="Whether the login was successful"
|
||||
)
|
||||
login_method: str = Field(
|
||||
max_length=50, description="Login method (password/oauth/etc.)"
|
||||
)
|
||||
|
||||
# Additional information
|
||||
notes: Optional[str] = Field(default=None, max_length=500, description="Additional notes")
|
||||
|
||||
notes: str | None = Field(
|
||||
default=None, max_length=500, description="Additional notes"
|
||||
)
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
Reference in New Issue
Block a user