fix: After the application name change - the application name on the demo page has not been updated#3800
Conversation
…demo page has not been updated
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| del_application_access_token(access_token) | ||
| return self.one(with_valid=False) | ||
|
|
||
| @staticmethod |
There was a problem hiding this comment.
There are a few areas to consider for improvement:
-
Code Duplication:
from common.cache_data.application_access_token_cache import del_application_access_token
This line can be moved out of the function, so it's only called once.
-
Redundant Code: The following lines:
access_token = hashlib.md5(str(uuid.uuid7()).encode()).hexdigest()[8:24] application_access_token = QuerySet(ApplicationAccessToken).filter(application_id=application.id).first() if application_access_token is None: application_access_token = ApplicationAccessToken(application_id=application.id, access_token=access_token, is_active=True) application_access_token.save() else: access_token = application_access_token.access_token
could be combined into one more concise statement using
get_or_createmethod:application_access_token, _ = ApplicationAccessToken.objects.get_or_create( application_id=application.id, defaults={'access_token': hashlib.md5(str(uuid.uuid7()).encode()).hexdigest()[8:24], 'is_active': True} )
-
Avoid Unused Imports:
Ensure that imports you're not actually using should be removed from your file. -
Documentation Comments:
Add comments where necessary to describe complex blocks of code or logic flows, which will make maintenance easier down the road.
Following these recommendations leads to cleaner and potentially more efficient code like this:
from langchain_mcp_adapters.client import MultiServerMCPClient
from rest_framework import serializers, status
from rest_framework.utils.formatting import lazy_format
from application.flow.common import Workflow
from application.models.application import (
Application,
ApplicationTypeChoices,
ApplicationKnowledgeMapping,
ApplicationFolder,
ApplicationVersion
)
from application.models.application_access_token import ApplicationAccessToken
from common import result
from common.database_model_manage import DatabaseModelManage
from common.db.search import native_search, native_page_search
from common.exception.app_exception import AppApiException
class YourClass:
# Function implementation here...
def publish(self, instance, with_valid=True):
# Function body remains largely the same...
@staticmethod
def get_or_update_app_access_token(application):
return ApplicationAccessToken.objects.get_or_create(
application_id=application.id,
defaults={
'access_token': hashlib.md5(str(uuid.uuid7()).encode()).hexdigest()[8:24],
'is_active': True
}
)
# Call within your method as needed:
token, created = get_or_update_app_access_token(instance.application)By applying some of these suggestions, your codebase becomes leaner while maintaining readability and functionality integrity.
fix: After the application name change - the application name on the demo page has not been updated