- Introduced new models for `Organization` and `ReviewTask` to manage organizations and review tasks. - Implemented API endpoints for CRUD operations on organizations and tasks, including scanning organizations for repositories and PRs. - Developed a background worker for sequential processing of review tasks with priority handling and automatic retries. - Created frontend components for managing organizations and monitoring task queues, including real-time updates and filtering options. - Added comprehensive documentation for organization features and quick start guides. - Fixed UI issues and improved navigation for better user experience.
39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
"""Organization model"""
|
|
|
|
from sqlalchemy import Column, Integer, String, Boolean, DateTime, JSON, Enum
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from datetime import datetime
|
|
import enum
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class OrganizationPlatformEnum(str, enum.Enum):
|
|
"""Git platform types"""
|
|
GITEA = "gitea"
|
|
GITHUB = "github"
|
|
BITBUCKET = "bitbucket"
|
|
|
|
|
|
class Organization(Base):
|
|
"""Organization model for tracking Git organizations"""
|
|
|
|
__tablename__ = "organizations"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, nullable=False) # Имя организации
|
|
platform = Column(Enum(OrganizationPlatformEnum), nullable=False)
|
|
base_url = Column(String, nullable=False) # https://git.example.com
|
|
api_token = Column(String, nullable=True) # Encrypted, optional (uses master token)
|
|
webhook_secret = Column(String, nullable=False)
|
|
config = Column(JSON, default=dict) # Review configuration
|
|
is_active = Column(Boolean, default=True)
|
|
last_scan_at = Column(DateTime, nullable=True) # Когда последний раз сканировали
|
|
created_at = Column(DateTime, default=datetime.utcnow, server_default=func.now())
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, server_default=func.now())
|
|
|
|
def __repr__(self):
|
|
return f"<Organization(id={self.id}, name={self.name}, platform={self.platform})>"
|
|
|