feat: show change timestamps in history compare
This commit is contained in:
@@ -639,7 +639,8 @@ def fetch_members_as_of(cur, as_of: datetime) -> list[dict[str, object]]:
|
||||
mv.photo_url,
|
||||
COALESCE(m.sort_order, 2147483647) AS sort_order,
|
||||
mv.created_at,
|
||||
mv.valid_from AS updated_at
|
||||
mv.valid_from AS updated_at,
|
||||
mv.valid_to AS history_valid_to
|
||||
FROM member_versions mv
|
||||
LEFT JOIN members m
|
||||
ON m.id = mv.member_id
|
||||
@@ -707,6 +708,7 @@ def build_member_compare_items(from_items: list[dict[str, object]], to_items: li
|
||||
"status": "added",
|
||||
"status_label": "신규",
|
||||
"categories": ["신규"],
|
||||
"changed_at": after.get("updated_at"),
|
||||
"changes": [],
|
||||
"before_lines": [],
|
||||
"after_lines": build_summary(after),
|
||||
@@ -721,6 +723,7 @@ def build_member_compare_items(from_items: list[dict[str, object]], to_items: li
|
||||
"status": "removed",
|
||||
"status_label": "삭제",
|
||||
"categories": ["삭제"],
|
||||
"changed_at": before.get("history_valid_to") or before.get("updated_at"),
|
||||
"changes": [],
|
||||
"before_lines": build_summary(before),
|
||||
"after_lines": [],
|
||||
@@ -757,6 +760,7 @@ def build_member_compare_items(from_items: list[dict[str, object]], to_items: li
|
||||
"status": "updated",
|
||||
"status_label": "변경",
|
||||
"categories": sorted(categories),
|
||||
"changed_at": after.get("updated_at") or before.get("updated_at"),
|
||||
"changes": changes,
|
||||
"before_lines": [f"{change['label']}: {change['before'] or '-'}" for change in changes],
|
||||
"after_lines": [f"{change['label']}: {change['after'] or '-'}" for change in changes],
|
||||
|
||||
@@ -862,6 +862,10 @@ body {
|
||||
width: 82px;
|
||||
}
|
||||
|
||||
.col-compare-date {
|
||||
width: 132px;
|
||||
}
|
||||
|
||||
.col-compare-category {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
@@ -1479,6 +1479,23 @@ function getListSearchEntries() {
|
||||
}));
|
||||
}
|
||||
|
||||
function formatCompareChangedAt(value) {
|
||||
const raw = String(value || '').trim();
|
||||
if (!raw) {
|
||||
return '-';
|
||||
}
|
||||
const date = new Date(raw);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return raw;
|
||||
}
|
||||
const year = date.getFullYear();
|
||||
const month = pad(date.getMonth() + 1);
|
||||
const day = pad(date.getDate());
|
||||
const hours = pad(date.getHours());
|
||||
const minutes = pad(date.getMinutes());
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
}
|
||||
|
||||
function renderListViewCompareTable() {
|
||||
const container = document.getElementById('list-table-container');
|
||||
if (!container) {
|
||||
@@ -1492,6 +1509,7 @@ function renderListViewCompareTable() {
|
||||
<tr>
|
||||
<th class="col-name">이름</th>
|
||||
<th class="col-compare-status">상태</th>
|
||||
<th class="col-compare-date">변경일시</th>
|
||||
<th class="col-compare-category">변경유형</th>
|
||||
<th>이전</th>
|
||||
<th>현재</th>
|
||||
@@ -1501,7 +1519,7 @@ function renderListViewCompareTable() {
|
||||
`;
|
||||
|
||||
if (!rows.length) {
|
||||
html += '<tr><td colspan="5" class="list-empty-cell">선택한 기간 사이의 구성원 변경 내역이 없습니다.</td></tr>';
|
||||
html += '<tr><td colspan="6" class="list-empty-cell">선택한 기간 사이의 구성원 변경 내역이 없습니다.</td></tr>';
|
||||
} else {
|
||||
rows.forEach((item) => {
|
||||
const categories = (item.categories || []).map((category) => `<span class="list-compare-chip">${escapeHtml(category)}</span>`).join('');
|
||||
@@ -1511,6 +1529,7 @@ function renderListViewCompareTable() {
|
||||
<tr id="list-compare-row-${item.member_id}">
|
||||
<td class="font-black text-slate-700">${escapeHtml(item.name || '-')}</td>
|
||||
<td><span class="list-compare-status list-compare-status-${escapeHtml(item.status || 'updated')}">${escapeHtml(item.status_label || '-')}</span></td>
|
||||
<td>${escapeHtml(formatCompareChangedAt(item.changed_at))}</td>
|
||||
<td><div class="list-compare-chip-group">${categories || '<span class="text-slate-300">-</span>'}</div></td>
|
||||
<td class="list-compare-cell">${beforeLines}</td>
|
||||
<td class="list-compare-cell">${afterLines}</td>
|
||||
|
||||
Reference in New Issue
Block a user