Skip to content

Commit

Permalink
Merge pull request #1659 from TencentBlueKing/develop
Browse files Browse the repository at this point in the history
v1.9.5
  • Loading branch information
zhu327 authored Nov 22, 2022
2 parents 694c2ea + c1aa878 commit 25b310e
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 15 deletions.
19 changes: 15 additions & 4 deletions frontend/src/components/choose-ip/grade/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
isLoading: false,
// 节点数据分页的limit
limit: 100,
offset: 0,
// limit: 11,
// 当前选择的链路
curChain: [],
Expand Down Expand Up @@ -761,13 +762,13 @@
}
},
async firstFetchResources () {
async firstFetchResources (offset = 0) {
// debugger
this.isLoading = true;
this.treeData = [];
const params = {
limit: this.limit,
offset: 0,
offset,
system_id: this.curChain[0].system_id,
type: this.curChain[0].id,
// parent_type: '',
Expand All @@ -781,8 +782,18 @@
res.data.results = res.data.results.filter(item => {
return this.curSelectionCondition.includes(item.id);
});
res.data.count = res.data.results.length;
if (!res.data.results.length) {
this.isLoading = true;
this.offset += 200;
this.firstFetchResources(this.offset);
return;
} else {
this.isLoading = false;
}
} else {
this.isLoading = false;
}
res.data.count = res.data.results.length;
const totalPage = Math.ceil(res.data.count / this.limit);
const isAsync = this.curChain.length > 1;
this.treeData = res.data.results.map(item => {
Expand Down Expand Up @@ -843,7 +854,7 @@
ellipsisCopy: true
});
} finally {
this.isLoading = false;
// this.isLoading = false;
}
},
Expand Down
9 changes: 9 additions & 0 deletions release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# V1.9.5

### 缺陷修复
* 修复用户组可能选择实例为空问题

### 功能优化
* 推荐操作只移除用户已有的实例
* 操作列表缓存一分钟

# V1.9.4

### 缺陷修复
Expand Down
2 changes: 1 addition & 1 deletion saas/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.4
1.9.5
7 changes: 3 additions & 4 deletions saas/backend/apps/policy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,13 @@ def list(self, request, *args, **kwargs):
subject = SvcSubject(type=SubjectType.USER.value, id=request.user.username)
own_policies = self.policy_query_biz.list_by_subject(system_id, subject)

own_action_id_set = {p.action_id for p in own_policies}
policy_list = PolicyBeanList(
system_id, [p for p in policy_list.policies if p.action_id not in own_action_id_set]
)
# 只移除用户已有的实例
policy_list = policy_list.sub(PolicyBeanList(system_id, own_policies))

policy_list.fill_empty_fields()

# 生成推荐的操作, 排除已生成推荐策略的操作
own_action_id_set = {p.action_id for p in own_policies}
actions, action_id_set = [], set()
for action_id in chain(*list(recommend_action_dict.values())):
if action_id in action_id_set: # 去重
Expand Down
2 changes: 2 additions & 0 deletions saas/backend/biz/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pydantic.main import BaseModel
from pydantic.tools import parse_obj_as

from backend.common.cache import cachedmethod
from backend.common.error_codes import error_codes
from backend.service.action import ActionList, ActionService
from backend.service.constants import ACTION_ALL, SubjectType
Expand Down Expand Up @@ -93,6 +94,7 @@ class ActionBiz:
resource_type_svc = ResourceTypeService()
policy_svc = PolicyQueryService()

@cachedmethod(timeout=1 * 60) # 缓存1分钟
def list(self, system_id: str) -> ActionBeanList:
actions = self.action_svc.list(system_id)
action_list = ActionBeanList(parse_obj_as(List[ActionBean], actions))
Expand Down
16 changes: 10 additions & 6 deletions saas/backend/service/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from typing import Any, Dict, List, Optional, Tuple

from backend.common.cache import Cache, CacheEnum, CacheKeyPrefixEnum, cachedmethod
from backend.common.error_codes import error_codes
from backend.component import iam, resource_provider
from backend.service.models.resource import ResourceApproverAttribute
from backend.util.basic import chunked
Expand Down Expand Up @@ -262,12 +263,15 @@ def fetch_instance_name(self, ids: List[str]) -> List[ResourceInstanceBaseInfo]:
# 未被缓存的需要实时查询
not_cached_ids = [_id for _id in ids if _id not in cache_id_name_map]
not_cached_results = self.fetch_instance_info(not_cached_ids, [self.name_attribute])
results.extend(
[
ResourceInstanceBaseInfo(id=i.id, display_name=i.attributes[self.name_attribute])
for i in not_cached_results
]
)

for one in not_cached_results:
if self.name_attribute not in one.attributes:
raise error_codes.RESOURCE_PROVIDER_VALIDATE_ERROR.format(
f"fetch_instance_info[system:{self.system_id} resource_type_id:{self.resource_type_id}"
+ f" resource_id:{one.id}] attribute:{self.name_attribute} must not be empty"
)

results.append(ResourceInstanceBaseInfo(id=one.id, display_name=one.attributes[self.name_attribute]))

return results

Expand Down
8 changes: 8 additions & 0 deletions saas/resources/version_log/V1.9.5_2022-11-22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# V1.9.5 版本更新日志

### 缺陷修复
* 修复用户组可能选择实例为空问题

### 功能优化
* 推荐操作只移除用户已有的实例
* 操作列表缓存一分钟
8 changes: 8 additions & 0 deletions saas/resources/version_log/V1.9.5_2022-11-22_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# V1.9.5 ChangeLog

### Bug Fixes
* Fix the problem that the user group may select an empty instance

### Optimization Updates
* The recommended action is to only remove instances that the user already has
* The operation list is cached for one minute

0 comments on commit 25b310e

Please sign in to comment.