Compare commits

..

No commits in common. "637fc7516ba61810f13a2495e6378e0ba0382ca6" and "19e62d87d4fda93589192e8ab353f23c6e4091fe" have entirely different histories.

9 changed files with 29 additions and 57 deletions

View File

@ -1,6 +1,6 @@
"""Cooldown model."""
from sqlalchemy import Column, String, DateTime, Integer, ForeignKey, UniqueConstraint
from sqlalchemy import Column, String, DateTime, Integer, ForeignKey
from sqlalchemy.dialects.postgresql import UUID, JSONB
from hubgw.models.base import Base
@ -9,9 +9,6 @@ class Cooldown(Base):
"""Cooldown model."""
__tablename__ = "hub_cooldowns"
__table_args__ = (
UniqueConstraint('player_uuid', 'cooldown_type', name='idx_hub_cooldowns_player_type'),
)
id = Column(UUID(as_uuid=True), primary_key=True, server_default="gen_random_uuid()")
player_uuid = Column(String(36), ForeignKey("luckperms_players.uuid", ondelete="CASCADE"), nullable=False, index=True)

View File

@ -1,6 +1,6 @@
"""Home model."""
from sqlalchemy import Column, Float, String, Boolean, ForeignKey, REAL, Text, UniqueConstraint
from sqlalchemy import Column, Float, String, Boolean, ForeignKey, REAL
from sqlalchemy.dialects.postgresql import UUID
from hubgw.models.base import Base
@ -9,17 +9,14 @@ class Home(Base):
"""Home model."""
__tablename__ = "hub_homes"
__table_args__ = (
UniqueConstraint('player_uuid', 'name', name='idx_hub_homes_player_name'),
)
id = Column(UUID(as_uuid=True), primary_key=True, server_default="gen_random_uuid()")
player_uuid = Column(String(36), ForeignKey("luckperms_players.uuid", ondelete="CASCADE"), nullable=False, index=True)
name = Column(String(255), nullable=False)
world = Column(Text, nullable=False)
x = Column(Float, nullable=False)
y = Column(Float, nullable=False)
z = Column(Float, nullable=False)
world = Column(String, nullable=False) # TEXT type
x = Column(Float, nullable=False) # DOUBLE PRECISION
y = Column(Float, nullable=False) # DOUBLE PRECISION
z = Column(Float, nullable=False) # DOUBLE PRECISION
yaw = Column(REAL, default=0.0)
pitch = Column(REAL, default=0.0)
is_public = Column(Boolean, default=False)

View File

@ -7,7 +7,6 @@ from sqlalchemy import (
BigInteger,
ForeignKey,
Integer,
Index,
)
from sqlalchemy.orm import relationship
@ -38,9 +37,6 @@ class LuckPermsUserPermission(Base):
"""LuckPerms User Permission model."""
__tablename__ = "luckperms_user_permissions"
__table_args__ = (
Index('idx_luckperms_user_permissions_lookup', 'uuid', 'permission', 'server', 'world'),
)
id = Column(Integer, primary_key=True, autoincrement=True)
uuid = Column(String(36), ForeignKey("luckperms_players.uuid", ondelete="CASCADE"), nullable=False, index=True)

View File

@ -1,6 +1,6 @@
"""Punishment model."""
from sqlalchemy import Column, String, DateTime, Boolean, Text, ForeignKey, CheckConstraint, Index
from sqlalchemy import Column, String, DateTime, Boolean, Text, ForeignKey
from sqlalchemy.dialects.postgresql import UUID, INET
from hubgw.models.base import Base
@ -9,21 +9,12 @@ class Punishment(Base):
"""Punishment model."""
__tablename__ = "hub_punishments"
__table_args__ = (
CheckConstraint(
"punishment_type IN ('BAN', 'MUTE', 'KICK', 'WARN', 'TEMPBAN', 'TEMPMUTE')",
name='check_punishment_type'
),
Index('idx_hub_punishments_player_active', 'player_uuid', 'is_active', postgresql_where=Column('is_active')),
Index('idx_hub_punishments_type_active', 'punishment_type', 'is_active', postgresql_where=Column('is_active')),
Index('idx_hub_punishments_player_ip', 'player_ip', postgresql_where=Column('player_ip') != None),
)
id = Column(UUID(as_uuid=True), primary_key=True, server_default="gen_random_uuid()")
player_uuid = Column(String(36), ForeignKey("luckperms_players.uuid", ondelete="CASCADE"), nullable=False, index=True)
player_name = Column(String(255), nullable=False)
player_ip = Column(INET)
punishment_type = Column(String(50), nullable=False)
punishment_type = Column(String(50), nullable=False) # BAN, MUTE, KICK, WARN, TEMPBAN, TEMPMUTE
reason = Column(Text, nullable=False)
staff_uuid = Column(String(36), ForeignKey("luckperms_players.uuid", ondelete="SET NULL"), nullable=False)
staff_name = Column(String(255), nullable=False)

View File

@ -1,8 +1,7 @@
"""Teleport History model."""
from sqlalchemy import Column, String, Float, ForeignKey, Text, DateTime
from sqlalchemy import Column, String, Float, ForeignKey
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.sql import func
from hubgw.models.base import Base
@ -13,14 +12,13 @@ class TeleportHistory(Base):
id = Column(UUID(as_uuid=True), primary_key=True, server_default="gen_random_uuid()")
player_uuid = Column(String(36), ForeignKey("luckperms_players.uuid", ondelete="CASCADE"), nullable=False, index=True)
from_world = Column(Text)
from_x = Column(Float) # DOUBLE PRECISION
from_y = Column(Float) # DOUBLE PRECISION
from_z = Column(Float) # DOUBLE PRECISION
to_world = Column(Text, nullable=False)
to_x = Column(Float, nullable=False) # DOUBLE PRECISION
to_y = Column(Float, nullable=False) # DOUBLE PRECISION
to_z = Column(Float, nullable=False) # DOUBLE PRECISION
from_world = Column(String)
from_x = Column(Float)
from_y = Column(Float)
from_z = Column(Float)
to_world = Column(String, nullable=False)
to_x = Column(Float, nullable=False)
to_y = Column(Float, nullable=False)
to_z = Column(Float, nullable=False)
tp_type = Column(String(50), nullable=False)
target_name = Column(String(255))
created_at = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
target_name = Column(String(255))

View File

@ -1,6 +1,6 @@
"""Warp model."""
from sqlalchemy import Column, String, Float, Boolean, REAL, Text, Index
from sqlalchemy import Column, String, Float, Boolean, REAL
from sqlalchemy.dialects.postgresql import UUID
from hubgw.models.base import Base
@ -9,17 +9,13 @@ class Warp(Base):
"""Warp model."""
__tablename__ = "hub_warps"
__table_args__ = (
Index('idx_hub_warps_world', 'world'),
Index('idx_hub_warps_public', 'is_public', postgresql_where=Column('is_public')),
)
id = Column(UUID(as_uuid=True), primary_key=True, server_default="gen_random_uuid()")
name = Column(String(255), nullable=False, unique=True, index=True)
world = Column(Text, nullable=False)
x = Column(Float, nullable=False)
y = Column(Float, nullable=False)
z = Column(Float, nullable=False)
world = Column(String, nullable=False) # TEXT type
x = Column(Float, nullable=False) # DOUBLE PRECISION
y = Column(Float, nullable=False) # DOUBLE PRECISION
z = Column(Float, nullable=False) # DOUBLE PRECISION
yaw = Column(REAL, default=0.0)
pitch = Column(REAL, default=0.0)
is_public = Column(Boolean, default=True)

View File

@ -1,6 +1,6 @@
"""Whitelist model."""
from sqlalchemy import Column, String, DateTime, Boolean, ForeignKey, Index
from sqlalchemy import Column, String, DateTime, Boolean, ForeignKey
from sqlalchemy.dialects.postgresql import UUID
from hubgw.models.base import Base
@ -9,10 +9,6 @@ class WhitelistEntry(Base):
"""Whitelist entry model."""
__tablename__ = "hub_whitelist"
__table_args__ = (
Index('idx_hub_whitelist_active', 'is_active', postgresql_where=Column('is_active')),
Index('idx_hub_whitelist_expires', 'expires_at', postgresql_where=Column('expires_at') != None),
)
id = Column(UUID(as_uuid=True), primary_key=True, server_default="gen_random_uuid()")
player_name = Column(String(255), nullable=False, unique=True, index=True)

View File

@ -32,5 +32,4 @@ class TeleportHistory(TeleportHistoryBase, BaseSchema):
"""Teleport history schema."""
id: UUID
player_uuid: str
created_at: datetime
player_uuid: str

View File

@ -29,7 +29,8 @@ class TeleportHistoryService:
to_z=entry.to_z,
tp_type=entry.tp_type,
target_name=entry.target_name,
created_at=entry.created_at
created_at=entry.created_at,
updated_at=entry.updated_at
)
async def list_player_teleports(self, player_uuid: str, limit: int = 100) -> List[TeleportHistory]:
@ -49,7 +50,8 @@ class TeleportHistoryService:
to_z=entry.to_z,
tp_type=entry.tp_type,
target_name=entry.target_name,
created_at=entry.created_at
created_at=entry.created_at,
updated_at=entry.updated_at
)
for entry in entries
]