Skip to content

Commit

Permalink
fix(open api v2): profiles list support lookup_field default value - …
Browse files Browse the repository at this point in the history
…username
  • Loading branch information
nannan00 committed Aug 9, 2024
1 parent 38ce5a9 commit dda458f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/bk-user/bkuser/apis/open_v2/serializers/profilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""

from typing import List

from rest_framework import serializers
Expand Down Expand Up @@ -84,6 +85,7 @@ class ProfileListInputSLZ(ProfileFieldsSLZ):
"create_time",
],
required=False,
default="username",
)
exact_lookups = StringArrayField(help_text="精确匹配字段", required=False)
fuzzy_lookups = StringArrayField(help_text="模糊匹配字段", required=False)
Expand Down
2 changes: 1 addition & 1 deletion src/bk-user/bkuser/apis/open_v2/views/profilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def _convert_lookup_field(lookup_field: str, is_exact: bool = True) -> str:
if lookup_field not in lookup_field_map:
raise error_codes.VALIDATION_ERROR.f(f"unsupported lookup field: {lookup_field}")

return lookup_field_map[lookup_field]
return lookup_field_map[lookup_field] if is_exact else f"{lookup_field_map[lookup_field]}__icontains"

@staticmethod
def _convert_status_lookup_to_query(values: List[str], is_exact: bool) -> Q | None:
Expand Down

0 comments on commit dda458f

Please sign in to comment.