Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix api route change . #1231

Merged
merged 1 commit into from
Feb 7, 2023
Merged
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
2 changes: 1 addition & 1 deletion dongtai_web/base/project_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def version_modify(user, department, versionData=None):

def get_project_version(project_id, auth_users=None):
versionInfo = IastProjectVersion.objects.filter(
project_id=project_id, status=1, current_version=1
project_id=project_id,
).first()
if versionInfo:
current_project_version = {
Expand Down
4 changes: 3 additions & 1 deletion dongtai_web/views/api_route_cover_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from dongtai_common.models.api_route import IastApiRoute, FromWhereChoices
from dongtai_web.utils import extend_schema_with_envcheck, get_response_serializer
from rest_framework import serializers
from dongtai_common.models.project import IastProject
import logging

logger = logging.getLogger("dongtai-webapi")
Expand Down Expand Up @@ -64,7 +65,8 @@ def get(self, request):
bind_project_id=project_id,
project_version_id=current_project_version.get("version_id",
0)).values("id")
q = Q(project_version_id=version_id, project_id=project_id)
q = Q(project_version_id=current_project_version.get("version_id", 0),
project_id=project_id)
queryset = IastApiRoute.objects.filter(q)
total = queryset.values("path").distinct().count()
cover_count = checkcover_batch(queryset, agents)
Expand Down
7 changes: 4 additions & 3 deletions dongtai_web/views/api_route_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ def post(self, request):
project_id)
else:
current_project_version = get_project_version_by_id(version_id)
departments = request.user.get_relative_department()
agents = IastAgent.objects.filter(
user__in=auth_users,
bind_project__department__in=departments,
bind_project_id=project_id,
project_version_id=current_project_version.get("version_id",
0)).values("id")
q = Q(agent_id__in=[_['id'] for _ in agents])
departments = request.user.get_relative_department()
projectexist = IastProject.objects.filter(department__in=departments,
pk=project_id).first()
if not projectexist:
Expand All @@ -190,7 +190,8 @@ def post(self, request):
bind_project_id=project_id,
project_version_id=current_project_version.get("version_id",
0)).values("id")
q = Q(project_version_id=version_id, project_id=project_id)
q = Q(project_version_id=current_project_version.get("version_id", 0),
project_id=project_id)
q = q & Q(
method_id__in=[_['id']
for _ in api_methods]) if api_methods != [] else q
Expand Down