feat: 修复排序中的空值错误
All checks were successful
CI Monitor MIflow / build-image (push) Successful in 42s
All checks were successful
CI Monitor MIflow / build-image (push) Successful in 42s
修复了在排序过程中出现空值的错误,以确保代码的稳定性和正确性。
This commit is contained in:
parent
d8ca8b531d
commit
e7dcd217fa
@ -39,7 +39,9 @@ const checkIsSuccess = async (
|
|||||||
if (!stage)
|
if (!stage)
|
||||||
return makeResult(
|
return makeResult(
|
||||||
pipeline.builds
|
pipeline.builds
|
||||||
.sort((a, b) => a.finished_at.localeCompare(b.finished_at))[0]
|
.sort((a, b) =>
|
||||||
|
(a.finished_at || "").localeCompare(b.finished_at || "")
|
||||||
|
)[0]
|
||||||
.id.toString(),
|
.id.toString(),
|
||||||
pipeline.object_attributes.status === "success"
|
pipeline.object_attributes.status === "success"
|
||||||
)
|
)
|
||||||
@ -52,7 +54,7 @@ const checkIsSuccess = async (
|
|||||||
return makeResult("", false)
|
return makeResult("", false)
|
||||||
// 按finished_at排序,获取最后一个运行的id
|
// 按finished_at排序,获取最后一个运行的id
|
||||||
const lastId = builds.sort((a, b) =>
|
const lastId = builds.sort((a, b) =>
|
||||||
a.finished_at.localeCompare(b.finished_at)
|
(a.finished_at || "").localeCompare(b.finished_at || "")
|
||||||
)[0].id
|
)[0].id
|
||||||
// 该ID的通知是否已经发送过
|
// 该ID的通知是否已经发送过
|
||||||
const notify = await db.notify.getOne(lastId.toString())
|
const notify = await db.notify.getOne(lastId.toString())
|
||||||
|
@ -288,7 +288,7 @@ export namespace Gitlab {
|
|||||||
* 构建的结束时间
|
* 构建的结束时间
|
||||||
* @example 2024-07-29 15:49:21 +0800
|
* @example 2024-07-29 15:49:21 +0800
|
||||||
*/
|
*/
|
||||||
finished_at: string
|
finished_at: string | null
|
||||||
}[]
|
}[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user