lyc8503 пре 3 година
родитељ
комит
0076d47502

+ 1 - 1
backend_refactor/service/photo_analyzer.py

@@ -29,7 +29,7 @@ class StandingPhotoAnalyzer(BasePhotoAnalyzer):
             photos = []
             npys = []
 
-            for index, i in enumerate(self.front, self.right):
+            for index, i in enumerate((self.front, self.right)):
                 test_image = UPLOAD_DIR + '{}.jpg'.format(i)
 
                 ori_img = cv2.imread(test_image)  # B,G,R order

+ 23 - 6
frontend_refactor/src/containers/TaskList.js

@@ -12,11 +12,14 @@ class TaskList extends React.Component {
     componentDidMount() {
         this.timer = setInterval(() => {
             this.props.tasks.forEach((x) => {
-                axios.get(BACKEND_URL + "/result/" + x).then(r => {
-                    this.state.details[x] = r.data.data
-                    this.state.details[x]['status'] = r.data.msg
-                    this.setState(this.state.details)
-                })
+
+                if (!(x in this.state.details) || this.state.details[x]['status'] == 'running') {
+                    axios.get(BACKEND_URL + "/result/" + x).then(r => {
+                        this.state.details[x] = r.data.data
+                        this.state.details[x]['status'] = r.data.msg
+                        this.setState(this.state.details)
+                    })
+                }
             })
         }, 2000)
     }
@@ -38,10 +41,24 @@ class TaskList extends React.Component {
                                 return <></>;
                             }
 
+                            let data = ""
+                            let advice = ""
+                            let raw = ""
+
+                            try {
+                                raw = JSON.stringify(details.result.raw)
+                                data = JSON.stringify(details.result.analysis.data)
+                                advice = JSON.stringify(details.result.analysis.advice)
+                            } catch (e) {
+
+                            }
+
                             return (
                                 <Collapse.Panel header={"任务 ID: " + x} key={x}>
                                     <p>状态: {details.status}</p>
-                                    <p>结果: {JSON.stringify(details.data)}</p>
+                                    <p>建议: {advice}</p>
+                                    <p>评分: {data}</p>
+                                    <p>原始数据: {raw}</p>
                                 </Collapse.Panel>
                             )
                         })