Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions server/src/routes/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { parse } from 'csv-parse/sync'
import { stringify } from 'csv-stringify/sync'
import { calcDurationDays } from '../utils/round.js'
import { pruneSnapshots } from '../lib/snapshotUtils.js'
import { buildSnapshot } from './snapshots.js'

const router = Router({ mergeParams: true })
router.use(authenticate)
Expand Down Expand Up @@ -518,18 +519,16 @@ router.post('/import-csv', asyncHandler(async (req: AuthRequest, res: Response)
rtByName.set(rtName.toLowerCase(), newRt)
}

// Auto-snapshot before import
const existingEpics = await prisma.epic.findMany({
where: { projectId },
include: { features: { include: { userStories: { include: { tasks: { include: { resourceType: true } } } } } } },
})
// Auto-snapshot before import using shared buildSnapshot() for full state capture
const existingEpics = await prisma.epic.findMany({ where: { projectId }, select: { id: true } })
if (existingEpics.length > 0) {
const snapshotData = await buildSnapshot(projectId)
await prisma.backlogSnapshot.create({
data: {
projectId,
label: 'Auto-snapshot before CSV import',
trigger: 'csv_import',
snapshot: existingEpics as unknown as object,
snapshot: snapshotData as unknown as object,
createdById: req.userId!,
},
})
Expand Down
Loading
Loading