-
Notifications
You must be signed in to change notification settings - Fork 2.8k
refactor: Optimization of operation menu #2717
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,8 @@ class Export(APIView): | |
| [lambda r, keywords: Permission(group=Group.APPLICATION, operate=Operate.USE, | ||
| dynamic_tag=keywords.get('application_id'))]) | ||
| ) | ||
| @log(menu='Conversation Log', operate="Export conversation", | ||
| get_operation_object=lambda r, k: get_application_operation_object(k.get('application_id'))) | ||
| def post(self, request: Request, application_id: str): | ||
| return ChatSerializers.Query( | ||
| data={**query_params_to_single_dict(request.query_params), 'application_id': application_id, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your code looks mostly well-structured, but there's one change needed to fix a syntax error: @@ -62,7 +64 @@ class Export(APIView):To correct the syntax error and ensure proper function definitions within your @post(...)
def post(self, request, application_id): # Note the removal of commas here due to incorrect indenting
... rest of the code ...Additionally, consider checking if If you need further optimization suggestions or additional improvements, please let me know! Otherwise, this should address any immediate issues found in your code. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,7 +129,16 @@ | |
| </div> | ||
| </template> | ||
| </el-table-column> | ||
| <el-table-column prop="operate" :label="$t('views.operateLog.table.operate.detail')" /> | ||
| <el-table-column prop="operate" :label="$t('views.operateLog.table.operate.detail')"> | ||
| <template #default="{ row }"> | ||
| {{ | ||
| row.operate + | ||
| (row.operation_object && row.operation_object.name | ||
| ? `【${row.operation_object.name}】` | ||
| : '') | ||
| }} | ||
| </template> | ||
| </el-table-column> | ||
| <el-table-column | ||
| width="120" | ||
| prop="user.username" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The modified line seems to correct a minor issue in how the operation details are displayed. The template expression now includes the operation object's name if it exists, separated by "【」" for clarity. Optimization Suggestions:
Here’s an improved version: <template>
<!-- ... -->
<el-table-column
prop="operate"
:label="$t('views.operateLog.table.operate.detail')"
>
<template #default="{ row }">
{{ row.operate }}
{{
row.operation_object && row.operation_object.name
? ` 【${row.operation_object.name}】`
: ''
}}
</template>
</el-table-column>
<!-- ... -->
</template>
<script setup lang="ts">
// No additional changes required unless further modifications are needed beyond this point
</script>This should handle the operation object display correctly while making the code more readable and maintaining good practices. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some concerns and suggestions for review:
Redundancy: The same
@logdecorator is applied multiple times with similar parameters on both classes (SpeechToTextandTextToSpeech). This redundancy can be removed, which makes the code cleaner.Functionality Duplication: Both functions in the post methods seem to have very similar logic. Extracting this common functionality into a separate method would make things more maintainable and reduce duplication.
Code Style: Ensure consistent spacing, alignment, and use of comments where necessary. Proper organization of the class hierarchy and function definitions will also improve readability.
Security: If there's sensitive information about the application ID being logged, consider implementing additional security measures such as anonymization or whitelisting specific IDs.
Here’s an optimized version of the code based on these suggestions:
Key Changes:
@logdecorators.apply_operationthat encapsulates duplicate logic.text_to_speechfor handling text-to-speech operations, andget_application_operation_object.@method_decoratorto apply the logging middleware globally.These changes should lead to cleaner, more organized, and potentially less error-prone code.