-
Notifications
You must be signed in to change notification settings - Fork 31
resolved the issue about Emergency and High-Severity Grievance. #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
30fef7d
8d846c8
1e2e57d
a1a1ea9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,14 +1,17 @@ | ||||||||||||
| from fastapi import APIRouter, Depends, HTTPException, Query, Request | ||||||||||||
| from sqlalchemy.orm import Session, joinedload | ||||||||||||
| from sqlalchemy import func | ||||||||||||
| from sqlalchemy import func, case | ||||||||||||
| from typing import List, Optional | ||||||||||||
| import os | ||||||||||||
| import json | ||||||||||||
| import logging | ||||||||||||
| from datetime import datetime, timezone | ||||||||||||
|
|
||||||||||||
| from backend.database import get_db | ||||||||||||
| Emergency-and-High-Severity-#290 | ||||||||||||
| from backend.models import Grievance, EscalationAudit, SeverityLevel | ||||||||||||
| from backend.models import Grievance, EscalationAudit, GrievanceFollower, ClosureConfirmation | ||||||||||||
| main | ||||||||||||
|
Comment on lines
+11
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unresolved merge conflict markers and duplicate imports — Lines 11 and 14 are conflict remnants. Lines 12 and 13 are two separate imports from 🐛 Proposed fix- Emergency-and-High-Severity-#290
- from backend.models import Grievance, EscalationAudit, SeverityLevel
- from backend.models import Grievance, EscalationAudit, GrievanceFollower, ClosureConfirmation
- main
+ from backend.models import Grievance, EscalationAudit, SeverityLevel, GrievanceFollower, ClosureConfirmation📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.14.14)[warning] 11-11: Unexpected indentation (invalid-syntax) [warning] 11-11: Expected an identifier, but found a keyword (invalid-syntax) [warning] 11-12: Expected an expression (invalid-syntax) [warning] 12-12: Expected a statement (invalid-syntax) [warning] 14-14: Unexpected indentation (invalid-syntax) 🤖 Prompt for AI Agents |
||||||||||||
| from backend.schemas import ( | ||||||||||||
| GrievanceSummaryResponse, EscalationAuditResponse, EscalationStatsResponse, | ||||||||||||
| ResponsibilityMapResponse, | ||||||||||||
|
|
@@ -44,6 +47,16 @@ def get_grievances( | |||||||||||
| if category: | ||||||||||||
| query = query.filter(Grievance.category == category) | ||||||||||||
|
|
||||||||||||
| # Priority Queue Logic: Sort by Severity (Critical > High > Medium > Low) then by Date (Oldest first for resolution) | ||||||||||||
| severity_order = case( | ||||||||||||
| (Grievance.severity == SeverityLevel.CRITICAL, 1), | ||||||||||||
| (Grievance.severity == SeverityLevel.HIGH, 2), | ||||||||||||
| (Grievance.severity == SeverityLevel.MEDIUM, 3), | ||||||||||||
| (Grievance.severity == SeverityLevel.LOW, 4), | ||||||||||||
| else_=5 | ||||||||||||
| ) | ||||||||||||
| query = query.order_by(severity_order.asc(), Grievance.created_at.asc()) | ||||||||||||
|
|
||||||||||||
| grievances = query.offset(offset).limit(limit).all() | ||||||||||||
|
|
||||||||||||
| # Convert to response format | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,6 +42,7 @@ async def create_issue( | |||||||||||||||
| background_tasks: BackgroundTasks, | ||||||||||||||||
| description: str = Form(..., min_length=10, max_length=1000), | ||||||||||||||||
| category: str = Form(..., pattern=f"^({'|'.join([cat.value for cat in IssueCategory])})$"), | ||||||||||||||||
| severity: str = Form('medium', pattern="^(low|medium|high|critical)$"), | ||||||||||||||||
| language: str = Form('en'), | ||||||||||||||||
| user_email: str = Form(None), | ||||||||||||||||
| latitude: float = Form(None, ge=-90, le=90), | ||||||||||||||||
|
|
@@ -187,7 +188,10 @@ async def create_issue( | |||||||||||||||
| longitude=longitude, | ||||||||||||||||
| location=location, | ||||||||||||||||
| action_plan=None, | ||||||||||||||||
| Emergency-and-High-Severity-#290 | ||||||||||||||||
| severity=severity | ||||||||||||||||
| integrity_hash=integrity_hash | ||||||||||||||||
| main | ||||||||||||||||
|
Comment on lines
+191
to
+194
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unresolved merge conflict markers in Lines 191 and 194 are conflict remnants. Additionally, line 192 ( 🐛 Proposed fix action_plan=None,
- Emergency-and-High-Severity-#290
- severity=severity
- integrity_hash=integrity_hash
- main
+ severity=severity,
+ integrity_hash=integrity_hash,📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.14.14)[warning] 191-192: Expected a parameter name (invalid-syntax) [warning] 191-191: Expected an identifier, but found a keyword (invalid-syntax) [warning] 193-193: Expected (invalid-syntax) [warning] 194-194: Expected (invalid-syntax) 🤖 Prompt for AI Agents |
||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| # Offload blocking DB operations to threadpool | ||||||||||||||||
|
|
@@ -592,6 +596,22 @@ def get_recent_issues( | |||||||||||||||
|
|
||||||||||||||||
| # Convert to Pydantic models for validation and serialization | ||||||||||||||||
| data = [] | ||||||||||||||||
| Emergency-and-High-Severity-#290 | ||||||||||||||||
| for i in issues: | ||||||||||||||||
| data.append(IssueSummaryResponse( | ||||||||||||||||
| id=i.id, | ||||||||||||||||
| category=i.category, | ||||||||||||||||
| description=i.description[:100] + "..." if len(i.description) > 100 else i.description, | ||||||||||||||||
| created_at=i.created_at, | ||||||||||||||||
| image_path=i.image_path, | ||||||||||||||||
| status=i.status, | ||||||||||||||||
| upvotes=i.upvotes if i.upvotes is not None else 0, | ||||||||||||||||
| location=i.location, | ||||||||||||||||
| latitude=i.latitude, | ||||||||||||||||
| longitude=i.longitude, | ||||||||||||||||
| severity=i.severity.value if hasattr(i.severity, 'value') else i.severity | ||||||||||||||||
| # action_plan is deferred and excluded | ||||||||||||||||
| ).model_dump(mode='json')) | ||||||||||||||||
| for row in results: | ||||||||||||||||
| # Manually construct dict from named tuple row to avoid full object overhead | ||||||||||||||||
| desc = row.description or "" | ||||||||||||||||
|
|
@@ -609,6 +629,7 @@ def get_recent_issues( | |||||||||||||||
| "latitude": row.latitude, | ||||||||||||||||
| "longitude": row.longitude | ||||||||||||||||
| }) | ||||||||||||||||
| main | ||||||||||||||||
|
|
||||||||||||||||
| # Thread-safe cache update | ||||||||||||||||
| recent_issues_cache.set(data, cache_key) | ||||||||||||||||
|
|
||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,11 +44,17 @@ class IssueSummaryResponse(BaseModel): | |
| location: Optional[str] = None | ||
| latitude: Optional[float] = None | ||
| longitude: Optional[float] = None | ||
| Emergency-and-High-Severity-#290 | ||
| severity: Optional[str] = "medium" | ||
| action_plan: Optional[Any] = None | ||
|
|
||
| model_config = ConfigDict(from_attributes=True) | ||
|
|
||
| model_config = ConfigDict(from_attributes=True) | ||
|
|
||
| class IssueResponse(IssueSummaryResponse): | ||
| action_plan: Optional[Union[Dict[str, Any], Any]] = Field(None, description="Generated action plan") | ||
| main | ||
|
Comment on lines
+47
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unresolved merge conflict markers and duplicate Lines 47 and 57 are leftover branch markers. Additionally, after removing them, 🐛 Proposed fix latitude: Optional[float] = None
longitude: Optional[float] = None
- Emergency-and-High-Severity-#290
severity: Optional[str] = "medium"
action_plan: Optional[Any] = None
model_config = ConfigDict(from_attributes=True)
- model_config = ConfigDict(from_attributes=True)
-
class IssueResponse(IssueSummaryResponse):
action_plan: Optional[Union[Dict[str, Any], Any]] = Field(None, description="Generated action plan")
- main🧰 Tools🪛 Ruff (0.14.14)[warning] 47-47: Unexpected indentation (invalid-syntax) [warning] 47-47: Expected an identifier, but found a keyword (invalid-syntax) [warning] 47-48: Expected an expression (invalid-syntax) [warning] 55-55: Expected a statement (invalid-syntax) [warning] 57-57: Unexpected indentation (invalid-syntax) 🤖 Prompt for AI Agents |
||
|
|
||
| class IssueCreateRequest(BaseModel): | ||
| description: str = Field(..., min_length=10, max_length=1000, description="Issue description") | ||
|
|
@@ -57,6 +63,7 @@ class IssueCreateRequest(BaseModel): | |
| latitude: Optional[float] = Field(None, ge=-90, le=90, description="Latitude coordinate") | ||
| longitude: Optional[float] = Field(None, ge=-180, le=180, description="Longitude coordinate") | ||
| location: Optional[str] = Field(None, max_length=200, description="Location description") | ||
| severity: Optional[str] = Field("medium", pattern="^(low|medium|high|critical)$", description="Severity level") | ||
|
|
||
| @field_validator('description') | ||
| @classmethod | ||
|
|
@@ -156,6 +163,7 @@ class NearbyIssueResponse(BaseModel): | |
| upvotes: int = Field(..., description="Number of upvotes") | ||
| created_at: datetime = Field(..., description="Issue creation timestamp") | ||
| status: str = Field(..., description="Issue status") | ||
| severity: str = Field(default="medium", description="Issue severity") | ||
|
|
||
|
|
||
| class DeduplicationCheckResponse(BaseModel): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unresolved git merge conflict markers — this file will not parse.
Lines 147 and 150 are leftover branch-name markers from an unresolved merge/rebase (
Emergency-and-High-Severity-#290andmain). Python will raise aSyntaxErroron import, preventing the entire backend from starting.Remove the conflict markers and keep only the intended code.
🐛 Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.14.14)
[warning] 147-147: Expected an identifier, but found a keyword
andthat cannot be used here(invalid-syntax)
[warning] 147-148: Expected an expression
(invalid-syntax)
🤖 Prompt for AI Agents