rework from modal to page
This commit is contained in:
@@ -318,7 +318,8 @@ async function getRequests(filters?: { status?: string; anfrager_id?: string })
|
||||
async function getMyRequests(userId: string) {
|
||||
const result = await pool.query(
|
||||
`SELECT a.*,
|
||||
(SELECT COUNT(*)::int FROM ausruestung_anfrage_positionen p WHERE p.anfrage_id = a.id) AS positionen_count
|
||||
(SELECT COUNT(*)::int FROM ausruestung_anfrage_positionen p WHERE p.anfrage_id = a.id) AS positionen_count,
|
||||
(SELECT COUNT(*)::int FROM ausruestung_anfrage_positionen p WHERE p.anfrage_id = a.id AND p.geliefert) AS geliefert_count
|
||||
FROM ausruestung_anfragen a
|
||||
WHERE a.anfrager_id = $1
|
||||
ORDER BY a.erstellt_am DESC`,
|
||||
|
||||
@@ -188,6 +188,40 @@ async function updateIssue(
|
||||
}
|
||||
}
|
||||
|
||||
async function addHistoryEntry(
|
||||
issueId: number,
|
||||
aktion: string,
|
||||
details: Record<string, unknown> | null,
|
||||
userId?: string,
|
||||
) {
|
||||
try {
|
||||
await pool.query(
|
||||
`INSERT INTO issue_historie (issue_id, aktion, details, erstellt_von)
|
||||
VALUES ($1, $2, $3, $4)`,
|
||||
[issueId, aktion, details ? JSON.stringify(details) : null, userId || null],
|
||||
);
|
||||
} catch (error) {
|
||||
logger.error('IssueService.addHistoryEntry failed', { error, issueId });
|
||||
}
|
||||
}
|
||||
|
||||
async function getHistory(issueId: number) {
|
||||
try {
|
||||
const result = await pool.query(
|
||||
`SELECT h.*, u.name AS erstellt_von_name
|
||||
FROM issue_historie h
|
||||
LEFT JOIN users u ON u.id = h.erstellt_von
|
||||
WHERE h.issue_id = $1
|
||||
ORDER BY h.erstellt_am DESC`,
|
||||
[issueId],
|
||||
);
|
||||
return result.rows;
|
||||
} catch (error) {
|
||||
logger.error('IssueService.getHistory failed', { error, issueId });
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteIssue(id: number) {
|
||||
try {
|
||||
const result = await pool.query(
|
||||
@@ -575,6 +609,8 @@ export default {
|
||||
getAssignableMembers,
|
||||
getIssueCounts,
|
||||
getIssueStatuses,
|
||||
addHistoryEntry,
|
||||
getHistory,
|
||||
createIssueStatus,
|
||||
updateIssueStatus,
|
||||
deleteIssueStatus,
|
||||
|
||||
Reference in New Issue
Block a user