Use constant in stead of hard code number for collapsible file list threadhold

This commit is contained in:
KennyDizi
2024-02-24 16:53:18 +07:00
parent 214f65902c
commit f3a712683a

View File

@ -42,6 +42,7 @@ class PRDescription:
# Initialize the AI handler # Initialize the AI handler
self.ai_handler = ai_handler() self.ai_handler = ai_handler()
# Initialize the variables dictionary # Initialize the variables dictionary
self.vars = { self.vars = {
"title": self.git_provider.pr.title, "title": self.git_provider.pr.title,
@ -58,6 +59,7 @@ class PRDescription:
self.user_description = self.git_provider.get_user_description() self.user_description = self.git_provider.get_user_description()
# Initialize the token handler # Initialize the token handler
self.token_handler = TokenHandler( self.token_handler = TokenHandler(
self.git_provider.pr, self.git_provider.pr,
@ -66,9 +68,11 @@ class PRDescription:
get_settings().pr_description_prompt.user, get_settings().pr_description_prompt.user,
) )
# Initialize patches_diff and prediction attributes # Initialize patches_diff and prediction attributes
self.patches_diff = None self.patches_diff = None
self.prediction = None self.prediction = None
COLLAPSIBLE_FILE_LIST_THRESHOLD = 8
async def run(self): async def run(self):
""" """
@ -359,7 +363,7 @@ class PRDescription:
for semantic_label in value.keys(): for semantic_label in value.keys():
num_files += len(value[semantic_label]) num_files += len(value[semantic_label])
if use_collapsible_file_list == "adaptive": if use_collapsible_file_list == "adaptive":
use_collapsible_file_list = num_files > 8 use_collapsible_file_list = num_files > COLLAPSIBLE_FILE_LIST_THRESHOLD
if not self.git_provider.is_supported("gfm_markdown"): if not self.git_provider.is_supported("gfm_markdown"):
get_logger().info(f"Disabling semantic files types for {self.pr_id} since gfm_markdown is not supported") get_logger().info(f"Disabling semantic files types for {self.pr_id} since gfm_markdown is not supported")