feat: 중복 신고 추적 시스템 구현 - 신고자 인지도 및 대응 속도 분석
🔄 Duplicate Tracking System: - 중복 신고 시 원본 이슈에 신고자 정보 자동 추가 - 신고 인지도 및 대응 속도 분석을 위한 데이터 수집 - 뒷북치는 신고자 파악 및 집계 기능 📊 Database Schema Updates: - duplicate_of_issue_id: 중복 대상 이슈 ID (FK) - duplicate_reporters: 중복 신고자 목록 (JSONB 배열) - 015_add_duplicate_tracking.sql 마이그레이션 실행 - GIN 인덱스로 JSONB 검색 성능 최적화 🔧 Backend Enhancements: - 중복 폐기 시 대상 이슈에 신고자 정보 자동 추가 - 신고자 중복 체크 로직 (동일 사용자 재추가 방지) - /api/inbox/management-issues API 추가 (중복 선택용) - 프로젝트별 관리함 이슈 목록 조회 지원 🎨 Frontend UI Improvements: - 중복 선택 시 관리함 이슈 목록 표시 - 프로젝트별 필터링된 이슈 목록 제공 - 간단한 이슈 정보 표시 (제목, 카테고리, 신고자, 중복 건수) - 직관적인 선택 UI (클릭으로 선택, 시각적 피드백) 📋 Duplicate Selection Process: 1. 폐기 사유로 '중복' 선택 2. 동일 프로젝트의 관리함 이슈 목록 자동 로드 3. 중복 대상 이슈 선택 (필수) 4. 확인 시 신고자 정보가 원본 이슈에 추가 💾 Data Structure: - duplicate_reporters: [ { user_id: 123, username: 'reporter1', full_name: '신고자1', report_date: '2024-10-25T14:30:00', added_at: '2024-10-25T15:00:00' } ] 🔍 Analytics Features: - 중복 신고 건수 표시 - 신고자별 신고 시점 추적 - 원본 이슈 대비 지연 신고 분석 가능 - 부서별/사용자별 인지도 분석 데이터 제공 🚀 User Experience: - 중복 처리 시 명확한 안내 메시지 - 관리함 이슈 목록 실시간 로드 - 선택 필수 검증 (중복 대상 미선택 시 경고) - 처리 완료 후 자동 목록 새로고침 Expected Result: ✅ 중복 신고 시 신고자 정보 자동 추적 ✅ 신고 인지도 및 대응 속도 분석 데이터 수집 ✅ 직관적인 중복 대상 선택 UI ✅ 부서별/개인별 신고 패턴 분석 기반 마련
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -115,10 +115,15 @@ class Issue(Base):
|
||||
original_data = Column(JSONB) # 원본 데이터 보존
|
||||
modification_log = Column(JSONB, default=lambda: []) # 수정 이력
|
||||
|
||||
# 중복 신고 추적 시스템
|
||||
duplicate_of_issue_id = Column(Integer, ForeignKey("issues.id")) # 중복 대상 이슈 ID
|
||||
duplicate_reporters = Column(JSONB, default=lambda: []) # 중복 신고자 목록
|
||||
|
||||
# Relationships
|
||||
reporter = relationship("User", back_populates="issues", foreign_keys=[reporter_id])
|
||||
reviewer = relationship("User", foreign_keys=[reviewed_by_id])
|
||||
reviewer = relationship("User", foreign_keys=[reviewed_by_id], overlaps="reviewed_issues")
|
||||
project = relationship("Project", back_populates="issues")
|
||||
duplicate_of = relationship("Issue", remote_side=[id], foreign_keys=[duplicate_of_issue_id])
|
||||
|
||||
class Project(Base):
|
||||
__tablename__ = "projects"
|
||||
|
||||
@@ -124,6 +124,10 @@ class Issue(IssueBase):
|
||||
original_data: Optional[Dict[str, Any]] = None
|
||||
modification_log: Optional[List[Dict[str, Any]]] = None
|
||||
|
||||
# 중복 신고 추적 시스템
|
||||
duplicate_of_issue_id: Optional[int] = None
|
||||
duplicate_reporters: Optional[List[Dict[str, Any]]] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
@@ -132,6 +136,7 @@ class IssueDisposalRequest(BaseModel):
|
||||
"""부적합 폐기 요청"""
|
||||
disposal_reason: DisposalReasonType = DisposalReasonType.duplicate
|
||||
custom_disposal_reason: Optional[str] = None
|
||||
duplicate_of_issue_id: Optional[int] = None # 중복 대상 이슈 ID
|
||||
|
||||
class IssueReviewRequest(BaseModel):
|
||||
"""부적합 검토 및 수정 요청"""
|
||||
|
||||
100
backend/migrations/015_add_duplicate_tracking.sql
Normal file
100
backend/migrations/015_add_duplicate_tracking.sql
Normal file
@@ -0,0 +1,100 @@
|
||||
-- 015_add_duplicate_tracking.sql
|
||||
-- 중복 신고 추적 시스템 추가
|
||||
|
||||
BEGIN;
|
||||
|
||||
-- migration_log 테이블 생성 (멱등성)
|
||||
CREATE TABLE IF NOT EXISTS migration_log (
|
||||
id SERIAL PRIMARY KEY,
|
||||
migration_file VARCHAR(255) NOT NULL UNIQUE,
|
||||
executed_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
status VARCHAR(50),
|
||||
notes TEXT,
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- 마이그레이션 파일 이름
|
||||
DO $$
|
||||
DECLARE
|
||||
migration_name VARCHAR(255) := '015_add_duplicate_tracking.sql';
|
||||
migration_notes TEXT := '중복 신고 추적 시스템: duplicate_of_issue_id, duplicate_reporters 컬럼 추가';
|
||||
current_status VARCHAR(50);
|
||||
BEGIN
|
||||
SELECT status INTO current_status FROM migration_log WHERE migration_file = migration_name;
|
||||
|
||||
IF current_status IS NULL THEN
|
||||
RAISE NOTICE '--- 마이그레이션 % 시작 ---', migration_name;
|
||||
|
||||
-- issues 테이블에 중복 추적 컬럼 추가
|
||||
-- 중복 대상 이슈 ID
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'duplicate_of_issue_id') THEN
|
||||
ALTER TABLE issues ADD COLUMN duplicate_of_issue_id INTEGER;
|
||||
RAISE NOTICE '✅ issues.duplicate_of_issue_id 컬럼이 추가되었습니다.';
|
||||
ELSE
|
||||
RAISE NOTICE 'ℹ️ issues.duplicate_of_issue_id 컬럼이 이미 존재합니다.';
|
||||
END IF;
|
||||
|
||||
-- 중복 신고자 목록 (JSONB 배열)
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'issues' AND column_name = 'duplicate_reporters') THEN
|
||||
ALTER TABLE issues ADD COLUMN duplicate_reporters JSONB DEFAULT '[]'::jsonb;
|
||||
RAISE NOTICE '✅ issues.duplicate_reporters 컬럼이 추가되었습니다.';
|
||||
ELSE
|
||||
RAISE NOTICE 'ℹ️ issues.duplicate_reporters 컬럼이 이미 존재합니다.';
|
||||
END IF;
|
||||
|
||||
-- 외래 키 제약 조건 추가 (duplicate_of_issue_id)
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'issues_duplicate_of_issue_id_fkey') THEN
|
||||
ALTER TABLE issues ADD CONSTRAINT issues_duplicate_of_issue_id_fkey
|
||||
FOREIGN KEY (duplicate_of_issue_id) REFERENCES issues(id);
|
||||
RAISE NOTICE '✅ issues_duplicate_of_issue_id_fkey 외래 키 제약 조건이 추가되었습니다.';
|
||||
ELSE
|
||||
RAISE NOTICE 'ℹ️ issues_duplicate_of_issue_id_fkey 외래 키 제약 조건이 이미 존재합니다.';
|
||||
END IF;
|
||||
|
||||
-- 인덱스 추가
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_indexes WHERE tablename = 'issues' AND indexname = 'idx_issues_duplicate_of') THEN
|
||||
CREATE INDEX idx_issues_duplicate_of ON issues (duplicate_of_issue_id) WHERE duplicate_of_issue_id IS NOT NULL;
|
||||
RAISE NOTICE '✅ idx_issues_duplicate_of 인덱스가 생성되었습니다.';
|
||||
ELSE
|
||||
RAISE NOTICE 'ℹ️ idx_issues_duplicate_of 인덱스가 이미 존재합니다.';
|
||||
END IF;
|
||||
|
||||
-- JSONB 인덱스 추가 (중복 신고자 검색 성능 향상)
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_indexes WHERE tablename = 'issues' AND indexname = 'idx_issues_duplicate_reporters_gin') THEN
|
||||
CREATE INDEX idx_issues_duplicate_reporters_gin ON issues USING GIN (duplicate_reporters);
|
||||
RAISE NOTICE '✅ idx_issues_duplicate_reporters_gin 인덱스가 생성되었습니다.';
|
||||
ELSE
|
||||
RAISE NOTICE 'ℹ️ idx_issues_duplicate_reporters_gin 인덱스가 이미 존재합니다.';
|
||||
END IF;
|
||||
|
||||
-- 마이그레이션 검증
|
||||
DECLARE
|
||||
col_count INTEGER;
|
||||
idx_count INTEGER;
|
||||
fk_count INTEGER;
|
||||
BEGIN
|
||||
SELECT COUNT(*) INTO col_count FROM information_schema.columns WHERE table_name = 'issues' AND column_name IN ('duplicate_of_issue_id', 'duplicate_reporters');
|
||||
SELECT COUNT(*) INTO idx_count FROM pg_indexes WHERE tablename = 'issues' AND indexname IN ('idx_issues_duplicate_of', 'idx_issues_duplicate_reporters_gin');
|
||||
SELECT COUNT(*) INTO fk_count FROM pg_constraint WHERE conname = 'issues_duplicate_of_issue_id_fkey';
|
||||
|
||||
RAISE NOTICE '=== 마이그레이션 검증 결과 ===';
|
||||
RAISE NOTICE '추가된 컬럼: %/2개', col_count;
|
||||
RAISE NOTICE '생성된 인덱스: %/2개', idx_count;
|
||||
RAISE NOTICE '생성된 FK: %/1개', fk_count;
|
||||
|
||||
IF col_count = 2 AND idx_count = 2 AND fk_count = 1 THEN
|
||||
RAISE NOTICE '✅ 마이그레이션이 성공적으로 완료되었습니다!';
|
||||
INSERT INTO migration_log (migration_file, status, notes) VALUES (migration_name, 'SUCCESS', migration_notes);
|
||||
ELSE
|
||||
RAISE EXCEPTION '❌ 마이그레이션 검증 실패!';
|
||||
END IF;
|
||||
END;
|
||||
|
||||
ELSIF current_status = 'SUCCESS' THEN
|
||||
RAISE NOTICE 'ℹ️ 마이그레이션 %는 이미 성공적으로 실행되었습니다. 스킵합니다.', migration_name;
|
||||
ELSE
|
||||
RAISE NOTICE '⚠️ 마이그레이션 %는 이전에 실패했습니다. 수동 확인이 필요합니다.', migration_name;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
COMMIT;
|
||||
Binary file not shown.
@@ -70,6 +70,32 @@ async def dispose_issue(
|
||||
"preserved_at": datetime.now().isoformat()
|
||||
}
|
||||
|
||||
# 중복 처리 로직
|
||||
if disposal_request.disposal_reason == DisposalReasonType.duplicate and disposal_request.duplicate_of_issue_id:
|
||||
# 중복 대상 이슈 확인
|
||||
target_issue = db.query(Issue).filter(Issue.id == disposal_request.duplicate_of_issue_id).first()
|
||||
if not target_issue:
|
||||
raise HTTPException(status_code=404, detail="중복 대상 이슈를 찾을 수 없습니다.")
|
||||
|
||||
# 중복 신고자를 대상 이슈에 추가
|
||||
current_reporters = target_issue.duplicate_reporters or []
|
||||
new_reporter = {
|
||||
"user_id": issue.reporter_id,
|
||||
"username": issue.reporter.username,
|
||||
"full_name": issue.reporter.full_name,
|
||||
"report_date": issue.report_date.isoformat() if issue.report_date else None,
|
||||
"added_at": datetime.now().isoformat()
|
||||
}
|
||||
|
||||
# 중복 체크 (이미 추가된 신고자인지 확인)
|
||||
existing_reporter = next((r for r in current_reporters if r.get("user_id") == issue.reporter_id), None)
|
||||
if not existing_reporter:
|
||||
current_reporters.append(new_reporter)
|
||||
target_issue.duplicate_reporters = current_reporters
|
||||
|
||||
# 현재 이슈에 중복 대상 설정
|
||||
issue.duplicate_of_issue_id = disposal_request.duplicate_of_issue_id
|
||||
|
||||
# 폐기 처리
|
||||
issue.review_status = ReviewStatus.disposed
|
||||
issue.disposal_reason = disposal_request.disposal_reason
|
||||
@@ -303,3 +329,38 @@ async def get_inbox_statistics(
|
||||
"total_in_management": management_count,
|
||||
"total_issues": db.query(Issue).count()
|
||||
}
|
||||
|
||||
@router.get("/management-issues")
|
||||
async def get_management_issues(
|
||||
project_id: Optional[int] = None,
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""관리함 이슈 목록 조회 (중복 선택용)"""
|
||||
try:
|
||||
query = db.query(Issue).filter(
|
||||
Issue.review_status.in_([ReviewStatus.in_progress, ReviewStatus.completed])
|
||||
)
|
||||
|
||||
# 프로젝트 필터 적용
|
||||
if project_id:
|
||||
query = query.filter(Issue.project_id == project_id)
|
||||
|
||||
issues = query.order_by(Issue.reviewed_at.desc()).limit(50).all()
|
||||
|
||||
# 간단한 형태로 반환 (제목과 ID만)
|
||||
result = []
|
||||
for issue in issues:
|
||||
result.append({
|
||||
"id": issue.id,
|
||||
"description": issue.description[:100] + "..." if len(issue.description) > 100 else issue.description,
|
||||
"category": issue.category.value,
|
||||
"reporter_name": issue.reporter.full_name or issue.reporter.username,
|
||||
"reviewed_at": issue.reviewed_at.isoformat() if issue.reviewed_at else None,
|
||||
"duplicate_count": len(issue.duplicate_reporters) if issue.duplicate_reporters else 0
|
||||
})
|
||||
|
||||
return result
|
||||
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"관리함 이슈 조회 중 오류가 발생했습니다: {str(e)}")
|
||||
|
||||
@@ -293,7 +293,7 @@
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">폐기 사유</label>
|
||||
<select id="disposalReason" class="w-full px-3 py-2 border border-gray-300 rounded-lg" onchange="toggleCustomReason()">
|
||||
<select id="disposalReason" class="w-full px-3 py-2 border border-gray-300 rounded-lg" onchange="toggleCustomReason(); toggleDuplicateSelection();">
|
||||
<option value="duplicate">중복 (기본)</option>
|
||||
<option value="invalid_report">잘못된 신고</option>
|
||||
<option value="not_applicable">해당 없음</option>
|
||||
@@ -308,6 +308,20 @@
|
||||
placeholder="폐기 사유를 입력하세요..."></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 중복 대상 선택 -->
|
||||
<div id="duplicateSelectionDiv" class="space-y-3">
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">중복 대상 선택</label>
|
||||
<p class="text-sm text-gray-600 mb-3">동일 프로젝트의 관리함에 있는 이슈 중 중복 대상을 선택하세요:</p>
|
||||
|
||||
<div id="managementIssuesList" class="max-h-48 overflow-y-auto border border-gray-200 rounded-lg">
|
||||
<div class="p-4 text-center text-gray-500">
|
||||
<i class="fas fa-spinner fa-spin mr-2"></i>관리함 이슈를 불러오는 중...
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="selectedDuplicateId" value="">
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end space-x-3">
|
||||
<button onclick="closeDisposeModal()" class="px-4 py-2 text-gray-600 hover:text-gray-800">
|
||||
취소
|
||||
@@ -916,7 +930,11 @@
|
||||
document.getElementById('disposalReason').value = 'duplicate';
|
||||
document.getElementById('customReason').value = '';
|
||||
document.getElementById('customReasonDiv').classList.add('hidden');
|
||||
document.getElementById('selectedDuplicateId').value = '';
|
||||
document.getElementById('disposeModal').classList.remove('hidden');
|
||||
|
||||
// 중복 선택 영역 표시 (기본값이 duplicate이므로)
|
||||
toggleDuplicateSelection();
|
||||
}
|
||||
|
||||
// 폐기 모달 닫기
|
||||
@@ -937,12 +955,103 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 중복 대상 선택 토글
|
||||
function toggleDuplicateSelection() {
|
||||
const reason = document.getElementById('disposalReason').value;
|
||||
const duplicateDiv = document.getElementById('duplicateSelectionDiv');
|
||||
|
||||
if (reason === 'duplicate') {
|
||||
duplicateDiv.classList.remove('hidden');
|
||||
loadManagementIssues();
|
||||
} else {
|
||||
duplicateDiv.classList.add('hidden');
|
||||
document.getElementById('selectedDuplicateId').value = '';
|
||||
}
|
||||
}
|
||||
|
||||
// 관리함 이슈 목록 로드
|
||||
async function loadManagementIssues() {
|
||||
const currentIssue = issues.find(issue => issue.id === currentIssueId);
|
||||
const projectId = currentIssue ? currentIssue.project_id : null;
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/inbox/management-issues${projectId ? `?project_id=${projectId}` : ''}`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${localStorage.getItem('access_token')}`
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('관리함 이슈 목록을 불러올 수 없습니다.');
|
||||
}
|
||||
|
||||
const managementIssues = await response.json();
|
||||
displayManagementIssues(managementIssues);
|
||||
|
||||
} catch (error) {
|
||||
console.error('관리함 이슈 로드 오류:', error);
|
||||
document.getElementById('managementIssuesList').innerHTML = `
|
||||
<div class="p-4 text-center text-red-500">
|
||||
<i class="fas fa-exclamation-triangle mr-2"></i>이슈 목록을 불러올 수 없습니다.
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
// 관리함 이슈 목록 표시
|
||||
function displayManagementIssues(managementIssues) {
|
||||
const container = document.getElementById('managementIssuesList');
|
||||
|
||||
if (managementIssues.length === 0) {
|
||||
container.innerHTML = `
|
||||
<div class="p-4 text-center text-gray-500">
|
||||
<i class="fas fa-inbox mr-2"></i>동일 프로젝트의 관리함 이슈가 없습니다.
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
container.innerHTML = managementIssues.map(issue => `
|
||||
<div class="p-3 border-b border-gray-100 hover:bg-gray-50 cursor-pointer"
|
||||
onclick="selectDuplicateTarget(${issue.id}, this)">
|
||||
<div class="flex items-start justify-between">
|
||||
<div class="flex-1">
|
||||
<div class="text-sm font-medium text-gray-900 mb-1">
|
||||
${issue.description}
|
||||
</div>
|
||||
<div class="flex items-center gap-2 text-xs text-gray-500">
|
||||
<span class="px-2 py-1 bg-gray-100 rounded">${getCategoryText(issue.category)}</span>
|
||||
<span>신고자: ${issue.reporter_name}</span>
|
||||
${issue.duplicate_count > 0 ? `<span class="text-orange-600">중복 ${issue.duplicate_count}건</span>` : ''}
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-xs text-gray-400">
|
||||
ID: ${issue.id}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
// 중복 대상 선택
|
||||
function selectDuplicateTarget(issueId, element) {
|
||||
// 이전 선택 해제
|
||||
document.querySelectorAll('#managementIssuesList > div').forEach(div => {
|
||||
div.classList.remove('bg-blue-50', 'border-blue-200');
|
||||
});
|
||||
|
||||
// 현재 선택 표시
|
||||
element.classList.add('bg-blue-50', 'border-blue-200');
|
||||
document.getElementById('selectedDuplicateId').value = issueId;
|
||||
}
|
||||
|
||||
// 폐기 확인
|
||||
async function confirmDispose() {
|
||||
if (!currentIssueId) return;
|
||||
|
||||
const disposalReason = document.getElementById('disposalReason').value;
|
||||
const customReason = document.getElementById('customReason').value;
|
||||
const duplicateId = document.getElementById('selectedDuplicateId').value;
|
||||
|
||||
// 사용자 정의 사유 검증
|
||||
if (disposalReason === 'custom' && !customReason.trim()) {
|
||||
@@ -950,22 +1059,39 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 중복 대상 선택 검증
|
||||
if (disposalReason === 'duplicate' && !duplicateId) {
|
||||
alert('중복 대상을 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const requestBody = {
|
||||
disposal_reason: disposalReason,
|
||||
custom_disposal_reason: disposalReason === 'custom' ? customReason : null
|
||||
};
|
||||
|
||||
// 중복 처리인 경우 대상 ID 추가
|
||||
if (disposalReason === 'duplicate' && duplicateId) {
|
||||
requestBody.duplicate_of_issue_id = parseInt(duplicateId);
|
||||
}
|
||||
|
||||
const response = await fetch(`/api/inbox/${currentIssueId}/dispose`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${localStorage.getItem('access_token')}`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
disposal_reason: disposalReason,
|
||||
custom_disposal_reason: disposalReason === 'custom' ? customReason : null
|
||||
})
|
||||
body: JSON.stringify(requestBody)
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
alert(`부적합이 성공적으로 폐기되었습니다.\n사유: ${getDisposalReasonText(disposalReason)}`);
|
||||
const message = disposalReason === 'duplicate'
|
||||
? '중복 신고가 처리되었습니다.\n신고자 정보가 원본 이슈에 추가되었습니다.'
|
||||
: `부적합이 성공적으로 폐기되었습니다.\n사유: ${getDisposalReasonText(disposalReason)}`;
|
||||
|
||||
alert(message);
|
||||
closeDisposeModal();
|
||||
await loadIssues(); // 목록 새로고침
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user