Skip to content
Closed

1 #7887

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,8 @@ dev-editor
*.rdb.gz

storybook-static
.venv
venv
.venv_bak
.gitignore
.trae/rules/project_rules.md
2 changes: 1 addition & 1 deletion apps/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "AGPL-3.0",
"private": true,
"scripts": {
"dev": "next dev --port 3001",
"dev": "next dev --port 3001 -H 0.0.0.0",
"build": "next build",
"preview": "next build && next start",
"start": "next start",
Expand Down
79 changes: 79 additions & 0 deletions apps/api/Dockerfile.django
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 使用Python 3.12官方镜像作为基础镜像
FROM python:3.12.10-alpine

# 设置环境变量
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV INSTANCE_CHANGELOG_URL=https://sites.plane.so/pages/691ef037bcfe416a902e48cb55f59891/

# 更新系统包以确保安全性
RUN apk update && apk upgrade

# 设置工作目录
WORKDIR /code

# 安装运行时依赖
RUN apk add --no-cache --upgrade \
"libpq" \
"libxslt" \
"xmlsec" \
"ca-certificates" \
"openssl" \
"bash~=5.2"

# 复制依赖文件
COPY requirements.txt ./
COPY requirements ./requirements

# 安装Python依赖
RUN apk add --no-cache libffi-dev && \
apk add --no-cache --virtual .build-deps \
"g++" \
"gcc" \
"cargo" \
"git" \
"make" \
"postgresql-dev" \
"libc-dev" \
"linux-headers" && \
pip install --upgrade pip && \
pip install -r requirements.txt --compile --no-cache-dir && \
apk del .build-deps && \
rm -rf /var/cache/apk/* && \
rm -rf /root/.cache/pip/*

# 复制Django项目文件
COPY manage.py manage.py
COPY plane plane/
COPY templates templates/
COPY package.json package.json

# 复制启动脚本
COPY ./bin ./bin/

# 创建必要的目录并设置权限
RUN mkdir -p /code/plane/logs && \
mkdir -p /code/uploads && \
chmod +x ./bin/* && \
chmod -R 777 /code

# 创建非root用户(安全最佳实践)
RUN addgroup -g 1001 -S appgroup && \
adduser -S appuser -u 1001 -G appgroup

# 更改文件所有权
RUN chown -R appuser:appgroup /code

# 切换到非root用户
USER appuser

# 暴露端口
EXPOSE 8000

# 设置健康检查
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD python manage.py check --deploy || exit 1

# 启动命令 - 使用本地开发启动脚本
CMD ["./bin/docker-entrypoint-api-local.sh"]
Empty file added apps/api/plane/api/models.py
Empty file.
9 changes: 6 additions & 3 deletions apps/api/plane/app/views/analytic/project_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_filtered_count() -> int:
}

def get_work_items_stats(
self, project_id, cycle_id=None, module_id=None
self, project_id, cycle_id=None, module_id=None
) -> Dict[str, Dict[str, int]]:
"""
Returns work item stats for the workspace, or filtered by cycle_id or module_id if provided.
Expand Down Expand Up @@ -91,6 +91,9 @@ def get_work_items_stats(
"completed_work_items": self.get_filtered_counts(
base_queryset.filter(state__group="completed")
),
"cancelled_work_items": self.get_filtered_counts(
base_queryset.filter(state__group="cancelled")
),
}

@allow_permission([ROLE.ADMIN, ROLE.MEMBER])
Expand Down Expand Up @@ -133,7 +136,7 @@ def get_project_issues_stats(self) -> QuerySet:
)

def get_work_items_stats(
self, project_id, cycle_id=None, module_id=None
self, project_id, cycle_id=None, module_id=None
) -> Dict[str, Dict[str, int]]:
base_queryset = None
if cycle_id is not None:
Expand Down Expand Up @@ -215,7 +218,7 @@ def get(self, request: HttpRequest, slug: str, project_id: str) -> Response:

class ProjectAdvanceAnalyticsChartEndpoint(ProjectAdvanceAnalyticsBaseView):
def work_item_completion_chart(
self, project_id, cycle_id=None, module_id=None
self, project_id, cycle_id=None, module_id=None
) -> Dict[str, Any]:
# Get the base queryset
queryset = (
Expand Down
Loading