Skip to content
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 apps/application/serializers/chat_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def one(self, current_role: RoleConstants, with_valid=True):
class Query(serializers.Serializer):
application_id = serializers.UUIDField(required=True)
chat_id = serializers.UUIDField(required=True)
order_asc = serializers.BooleanField(required=False)
order_asc = serializers.BooleanField(required=False, allow_null=True)

def list(self, with_valid=True):
if with_valid:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the provided code for one method within a class Query, there is no significant issue that can be identified. However, a minor enhancement could be made:

Change:

order_asc = serializers.BooleanField(required=False)

To:

order_asc = serializers.NullBooleanField(required=False)

By using NullBooleanField, you explicitly denote that this field can have three values: True, False, or None. This aligns better with how many applications might handle null/empty boolean flags to indicate default or unspecified behavior.

The rest of the code checks out well and doesn't contain irregularities or serious issues. If with_valid parameter is set to True, it seems you intend to include only validated data; otherwise, all records should be returned regardless.

Expand Down
5 changes: 5 additions & 0 deletions apps/application/swagger_api/chat_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ def get_request_params_api():
type=openapi.TYPE_STRING,
required=True,
description=_('Conversation ID')),
openapi.Parameter(name='order_asc',
in_=openapi.IN_QUERY,
type=openapi.TYPE_BOOLEAN,
required=False,
description=_('Is it ascending order')),
]

@staticmethod
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code snippet is mostly correct for defining API request parameters using the openapi library, which appears to be part of Swagger documentation generation tools like OpenAPI Generator. However, there are a few minor improvements and checks you might want to consider:

  1. Parameter Ordering: The order of parameters in the list is already consistent, so this isn't an issue.

  2. Description Updates: Consider adding more detailed descriptions if available, especially since the current ones seem quite brief and may not capture all aspects of what each parameter represents.

  3. Validation: Ensure that any validation logic related to these parameters is correctly implemented elsewhere in your application. If they need specific types or conditions, make sure those rules are enforced as well.

  4. Future Readability: You might want to include comments at the beginning of the function or within blocks explaining complex logical flows associated with handling these query parameters.

  5. Consistency with Others: It would be beneficial to review how similar or duplicate parameters are handled across other endpoints in your API to maintain consistency and reduce redundancy.

In summary, the code looks good from a syntax perspective and should work as intended. For further optimization, particularly focusing on readability and completeness, additional context and detail might be helpful.

Expand Down
3 changes: 3 additions & 0 deletions apps/locales/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6764,3 +6764,6 @@ msgstr ""

msgid "The network is busy, try again later."
msgstr ""

msgid "Is it ascending order"
msgstr ""
5 changes: 4 additions & 1 deletion apps/locales/zh_CN/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6902,4 +6902,7 @@ msgid "AI reply: "
msgstr "AI 回复: "

msgid "The network is busy, try again later."
msgstr "网络繁忙,请稍后再试。"
msgstr "网络繁忙,请稍后再试。"

msgid "Is it ascending order"
msgstr "是否升序"
5 changes: 4 additions & 1 deletion apps/locales/zh_Hant/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6914,4 +6914,7 @@ msgid "AI reply: "
msgstr "AI 回覆: "

msgid "The network is busy, try again later."
msgstr "網絡繁忙,請稍後再試。"
msgstr "網絡繁忙,請稍後再試。"

msgid "Is it ascending order"
msgstr "是否昇冪"