Spaces:
Sleeping
Sleeping
def format_log_file_name_timestamp(timestamp):
Browse files
app.py
CHANGED
@@ -694,13 +694,21 @@ def get_logs_sessions(user_data, log_type):
|
|
694 |
# file_names sort by timestamp DESC
|
695 |
file_names.sort(reverse=True)
|
696 |
choices = [
|
697 |
-
(file_name.split("/")[-1].split(".")[0], file_name)
|
|
|
698 |
]
|
699 |
|
700 |
paragraph_logs_session_list = gr.update(choices=choices, interactive=True, visible=True)
|
701 |
|
702 |
return paragraph_logs_session_list
|
703 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
704 |
def get_paragraph_practice_log_session_content(file_name):
|
705 |
if file_name:
|
706 |
content = GCS_SERVICE.download_as_string("jutor_logs", file_name)
|
|
|
694 |
# file_names sort by timestamp DESC
|
695 |
file_names.sort(reverse=True)
|
696 |
choices = [
|
697 |
+
(format_log_file_name_timestamp(file_name.split("/")[-1].split(".")[0]), file_name)
|
698 |
+
for file_name in file_names
|
699 |
]
|
700 |
|
701 |
paragraph_logs_session_list = gr.update(choices=choices, interactive=True, visible=True)
|
702 |
|
703 |
return paragraph_logs_session_list
|
704 |
|
705 |
+
def format_log_file_name_timestamp(timestamp):
|
706 |
+
# 假設時間戳格式為 "YYYY-MM-DD-HH-MM-SS"
|
707 |
+
parts = timestamp.split("-")
|
708 |
+
if len(parts) == 6:
|
709 |
+
return f"{'-'.join(parts[:3])} {':'.join(parts[3:])}"
|
710 |
+
return timestamp # 如果格式不符合預期,則返回原始字符串
|
711 |
+
|
712 |
def get_paragraph_practice_log_session_content(file_name):
|
713 |
if file_name:
|
714 |
content = GCS_SERVICE.download_as_string("jutor_logs", file_name)
|