agregar sprint, has_impairment, tabla impairments + sync pendings KAPPA
This commit is contained in:
+38
-4
@@ -1,17 +1,18 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
import { kappa } from '@/services/kappa-api'
|
||||
import { tauriDb, type UserStoryRecord, type EpicRecord } from '@/services/tauri-db'
|
||||
import { tauriDb, type UserStoryRecord, type EpicRecord, type ImpairmentRecord } from '@/services/tauri-db'
|
||||
import { stripHtml } from '@/services/clean-html'
|
||||
import { criteriaToJson, parseQuillList } from '@/services/clean-html'
|
||||
import { parseHierarchy, stripHierarchy, getItemType, type ItemType } from '@/services/hierarchy'
|
||||
import type { KappaUserStory, KappaLogbookEntry, KappaPlanningEntry, KappaEpicDevelopment } from '@/types/kappa'
|
||||
import type { KappaUserStory, KappaLogbookEntry, KappaPlanningEntry, KappaEpicDevelopment, KappaPending } from '@/types/kappa'
|
||||
|
||||
export interface EnrichedUserStory extends KappaUserStory {
|
||||
_itemType: ItemType
|
||||
_hierarchyPath: string | null
|
||||
_cleanTitle: string
|
||||
_criteriaList: string[]
|
||||
has_impairment: boolean
|
||||
}
|
||||
|
||||
export interface EnrichedEpic extends KappaEpicDevelopment {
|
||||
@@ -71,6 +72,7 @@ export const useWorkItemsStore = defineStore('workitems', () => {
|
||||
_hierarchyPath: h?.fullPath ?? null,
|
||||
_cleanTitle: h ? stripHierarchy(hu.title || '') : (hu.title || ''),
|
||||
_criteriaList: criteriaList,
|
||||
has_impairment: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,8 +168,19 @@ export const useWorkItemsStore = defineStore('workitems', () => {
|
||||
console.log(`[Alpha] Syncing ${hus.length} HUs to Turso for project ${projectId}`)
|
||||
for (const hu of hus) {
|
||||
try {
|
||||
const huId = Number(hu.id) || 0
|
||||
|
||||
// Consultar impedimentos en KAPPA
|
||||
let hasImpairment = false
|
||||
let impairments: KappaPending[] = []
|
||||
try {
|
||||
const pendingResp = await kappa.getPendings(huId)
|
||||
impairments = pendingResp.results
|
||||
hasImpairment = impairments.some(p => !p.status)
|
||||
} catch {}
|
||||
|
||||
await tauriDb.saveUserStory({
|
||||
id: Number(hu.id) || 0,
|
||||
id: huId,
|
||||
initiative_id: projectId,
|
||||
epic_id: null,
|
||||
code: safeStr(hu.code),
|
||||
@@ -176,12 +189,33 @@ export const useWorkItemsStore = defineStore('workitems', () => {
|
||||
acceptance_criteria: (hu.acceptance_criteria || hu.criterios_aceptacion || null) as string | null,
|
||||
status: safeStr(hu.status),
|
||||
priority: safeStr(hu.priority),
|
||||
story_points: null,
|
||||
story_points: hu.story_points ?? null,
|
||||
estimated_hours: null,
|
||||
actual_hours: null,
|
||||
assigned_to: null,
|
||||
sprint: safeStr(hu.sprint),
|
||||
has_impairment: hasImpairment,
|
||||
item_type: null,
|
||||
hierarchy_path: null,
|
||||
parent_code: null,
|
||||
created_at: null,
|
||||
})
|
||||
|
||||
// Guardar impedimentos en Turso
|
||||
for (const p of impairments) {
|
||||
await tauriDb.saveImpairment({
|
||||
id: p.id,
|
||||
hu_id: huId,
|
||||
responsible: p.responsible || null,
|
||||
pending_activity: p.pending_activity || null,
|
||||
pending_type: p.type || null,
|
||||
type_impediment: p.type_impediment,
|
||||
delivery_date: p.delivery_date || null,
|
||||
status: p.status,
|
||||
created_at: p.created_at || null,
|
||||
updated_at: p.updated_at || null,
|
||||
}).catch(() => {})
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`[Alpha] Failed to save HU ${hu.id}:`, e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user