-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:add progress functionality to the details page.
- Loading branch information
1 parent
83e22da
commit dd3cc71
Showing
23 changed files
with
1,210 additions
and
88 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
185 changes: 185 additions & 0 deletions
185
data-processing/data_manipulation/database_operate/data_process_document_db_operate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
# Copyright 2023 KubeAGI. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import ulid | ||
from database_clients import postgresql_pool_client | ||
from utils import date_time_utils | ||
|
||
def add( | ||
req_json, | ||
pool | ||
): | ||
"""Add a new record""" | ||
now = date_time_utils.now_str() | ||
user = req_json['creator'] | ||
program = '数据处理文件进度-新增' | ||
|
||
params = { | ||
'id': req_json['id'], | ||
'file_name': req_json['file_name'], | ||
'status': req_json['status'], | ||
'progress': req_json['progress'], | ||
'task_id': req_json['task_id'], | ||
'create_datetime': now, | ||
'create_user': user, | ||
'create_program': program, | ||
'update_datetime': now, | ||
'update_user': user, | ||
'update_program': program | ||
} | ||
|
||
sql = """ | ||
insert into public.data_process_task_document ( | ||
id, | ||
file_name, | ||
status, | ||
progress, | ||
task_id, | ||
create_datetime, | ||
create_user, | ||
create_program, | ||
update_datetime, | ||
update_user, | ||
update_program | ||
) | ||
values ( | ||
%(id)s, | ||
%(file_name)s, | ||
%(status)s, | ||
%(progress)s, | ||
%(task_id)s, | ||
%(create_datetime)s, | ||
%(create_user)s, | ||
%(create_program)s, | ||
%(update_datetime)s, | ||
%(update_user)s, | ||
%(update_program)s | ||
) | ||
""".strip() | ||
|
||
res = postgresql_pool_client.execute_update(pool, sql, params) | ||
return res | ||
|
||
def update_document_status_and_start_time( | ||
req_json, | ||
pool | ||
): | ||
"""Update the status and start time with id""" | ||
now = req_json['start_time'] | ||
program = '文件开始处理-修改' | ||
|
||
params = { | ||
'id': req_json['id'], | ||
'status': req_json['status'], | ||
'start_time': now, | ||
'chunk_size': req_json['chunk_size'], | ||
'update_datetime': now, | ||
'update_program': program | ||
} | ||
|
||
sql = """ | ||
update public.data_process_task_document set | ||
status = %(status)s, | ||
start_time = %(start_time)s, | ||
chunk_size = %(chunk_size)s, | ||
update_datetime = %(update_datetime)s, | ||
update_program = %(update_program)s | ||
where | ||
id = %(id)s | ||
""".strip() | ||
|
||
res = postgresql_pool_client.execute_update(pool, sql, params) | ||
return res | ||
|
||
def update_document_status_and_end_time( | ||
req_json, | ||
pool | ||
): | ||
"""Update the status and start time with id""" | ||
now = req_json['end_time'] | ||
program = '文件处理完成-修改' | ||
|
||
params = { | ||
'id': req_json['id'], | ||
'status': req_json['status'], | ||
'end_time': now, | ||
'update_datetime': now, | ||
'update_program': program | ||
} | ||
|
||
sql = """ | ||
update public.data_process_task_document set | ||
status = %(status)s, | ||
end_time = %(end_time)s, | ||
update_datetime = %(update_datetime)s, | ||
update_program = %(update_program)s | ||
where | ||
id = %(id)s | ||
""".strip() | ||
|
||
res = postgresql_pool_client.execute_update(pool, sql, params) | ||
return res | ||
|
||
def update_document_progress( | ||
req_json, | ||
pool | ||
): | ||
"""Update the progress with id""" | ||
now = date_time_utils.now_str() | ||
program = '文件处理进度-修改' | ||
|
||
params = { | ||
'id': req_json['id'], | ||
'progress': req_json['progress'], | ||
'update_datetime': now, | ||
'update_program': program | ||
} | ||
|
||
sql = """ | ||
update public.data_process_task_document set | ||
progress = %(progress)s, | ||
update_datetime = %(update_datetime)s, | ||
update_program = %(update_program)s | ||
where | ||
id = %(id)s | ||
""".strip() | ||
|
||
res = postgresql_pool_client.execute_update(pool, sql, params) | ||
return res | ||
|
||
def list_file_by_task_id( | ||
req_json, | ||
pool | ||
): | ||
"""info with id""" | ||
params = { | ||
'task_id': req_json['task_id'] | ||
} | ||
|
||
sql = """ | ||
select | ||
id, | ||
file_name, | ||
status, | ||
start_time, | ||
end_time, | ||
progress | ||
from | ||
public.data_process_task_document | ||
where | ||
task_id = %(task_id)s | ||
""".strip() | ||
|
||
res = postgresql_pool_client.execute_query(pool, sql, params) | ||
return res |
Oops, something went wrong.