Browse Source

🐞 fix: 修复仓库扫描接口中部分错误

Pchen. 2 months ago
parent
commit
01de19e4e0
3 changed files with 7 additions and 4 deletions
  1. 1 1
      apis/AI/GetScanTaskList.js
  2. 2 3
      apis/AI/ScanRepo.js
  3. 4 0
      apis/Repos/GetCommitDetail.js

+ 1 - 1
apis/AI/GetScanTaskList.js

@@ -24,7 +24,7 @@ class GetScanTaskList extends API {
                 ...BaseStdResponse.ACCESS_DENIED
             })
 
-        let sql = 'SELECT create_time, start_time, end_time, result, repo_hash, state, repo_id FROM scan_tasks WHERE create_user = ? AND repo_id = ?'
+        let sql = 'SELECT create_time, scan_start_time, scan_end_time, result, repo_hash, state, repo_id FROM scan_tasks WHERE create_user = ? AND repo_id = ?'
         let rows = await db.query(sql, [uuid, id])
 
         if (!rows || rows.length === 0)

+ 2 - 3
apis/AI/ScanRepo.js

@@ -56,13 +56,12 @@ class ScanRepo extends API {
                     msg: '扫描任务添加失败!'
                 })
 
-            let endpoint = core_url + '/ai/scan'
-            const res = await axios.post(endpoint, { uuid, repo_url: rows[0].url, task_id: String(r.insertId) })
-
             res.json({
                 ...BaseStdResponse.OK
             })
 
+            let endpoint = core_url + '/ai/scan'
+            await axios.post(endpoint, { uuid, repo_url: rows[0].url, task_id: String(r.insertId) })
         } catch (error) {
             this.logger.error('获取仓库历史失败!' + error.stack)
         }

+ 4 - 0
apis/Repos/GetCommitDetail.js

@@ -51,6 +51,8 @@ class GetCommitDetail extends API {
                         msg: '获取提交详情失败!'
                     })
 
+                console.log(result)
+
                 // 修改正则表达式,捕获多行 commit message(包括 body)
                 const commitRegex = /^commit (\w+)\nAuthor: (.+) <(.+)>\nDate:\s+(.+)\n\n([\s\S]+?)(?=diff --git|$)/;
                 const match = result.match(commitRegex)
@@ -87,6 +89,8 @@ class GetCommitDetail extends API {
                     })
                 }
 
+                console.log(commitInfo)
+
                 res.json({
                     ...BaseStdResponse.OK,
                     data: commitInfo