From 738918f6c6a3fe1e6ae6c8b7f125feb132936c21 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Mon, 13 Nov 2023 10:36:32 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=8E=AF=E5=A2=83=E6=A3=80?=
 =?UTF-8?q?=E6=B5=8B=E8=BF=9B=E5=BA=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 views/server.py | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/views/server.py b/views/server.py
index b13d908..c959c2a 100644
--- a/views/server.py
+++ b/views/server.py
@@ -264,4 +264,32 @@ def get_repo_data(data):
             data['centos8_aarch64'] = 'faild'
 
         json_data = json.dumps(data)
-        return json_data
\ No newline at end of file
+        return json_data
+
+
+def get_environment_data(data):
+    """
+    获取环境检查进度
+    :return:
+    """
+    get_environment_pro_sql = "select agent_ip,task_progress,task_status from agent_task;"
+    progress = DBHelper().execute(get_environment_pro_sql).fetchall()
+    res = {}
+    info_list = []
+    finall_progress = []
+    for i in progress:
+        sql = "select agent_id from agent_info where agent_ip='%s' and agent_online_status=0 and repo_status=0 " \
+              "and agent_storage>=10 and agent_migration_os is null;" % i[0]
+        get_sql = DBHelper().execute(sql).fetchall()
+        if get_sql:
+            finall_progress.append(list(i))
+
+    info_dict_keys_list = ['agent_ip', 'task_progress', 'task_status']
+    for i in finall_progress:
+        info_list.append(dict(zip(info_dict_keys_list, list(i))))
+
+    res['info'] = info_list
+    res['num'] = len(finall_progress)
+
+    json_res = json.dumps(res)
+    return json_res
\ No newline at end of file
-- 
2.20.1

