mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-10-29 02:53:37 +00:00
Added Total Packages in the Agent history
Added Script execution time in the Agent history tab Added Pagination for the agent History
This commit is contained in:
@@ -347,32 +347,41 @@ router.get(
|
||||
try {
|
||||
const { hostId } = req.params;
|
||||
|
||||
const host = await prisma.hosts.findUnique({
|
||||
where: { id: hostId },
|
||||
include: {
|
||||
host_groups: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
color: true,
|
||||
const limit = parseInt(req.query.limit) || 10;
|
||||
const offset = parseInt(req.query.offset) || 0;
|
||||
|
||||
const [host, totalHistoryCount] = await Promise.all([
|
||||
prisma.hosts.findUnique({
|
||||
where: { id: hostId },
|
||||
include: {
|
||||
host_groups: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
color: true,
|
||||
},
|
||||
},
|
||||
host_packages: {
|
||||
include: {
|
||||
packages: true,
|
||||
},
|
||||
orderBy: {
|
||||
needs_update: "desc",
|
||||
},
|
||||
},
|
||||
update_history: {
|
||||
orderBy: {
|
||||
timestamp: "desc",
|
||||
},
|
||||
take: limit,
|
||||
skip: offset,
|
||||
},
|
||||
},
|
||||
host_packages: {
|
||||
include: {
|
||||
packages: true,
|
||||
},
|
||||
orderBy: {
|
||||
needs_update: "desc",
|
||||
},
|
||||
},
|
||||
update_history: {
|
||||
orderBy: {
|
||||
timestamp: "desc",
|
||||
},
|
||||
take: 10,
|
||||
},
|
||||
},
|
||||
});
|
||||
}),
|
||||
prisma.update_history.count({
|
||||
where: { host_id: hostId },
|
||||
}),
|
||||
]);
|
||||
|
||||
if (!host) {
|
||||
return res.status(404).json({ error: "Host not found" });
|
||||
@@ -388,6 +397,12 @@ router.get(
|
||||
(hp) => hp.needs_update && hp.is_security_update,
|
||||
).length,
|
||||
},
|
||||
pagination: {
|
||||
total: totalHistoryCount,
|
||||
limit,
|
||||
offset,
|
||||
hasMore: offset + limit < totalHistoryCount,
|
||||
},
|
||||
};
|
||||
|
||||
res.json(hostWithStats);
|
||||
|
||||
Reference in New Issue
Block a user