feat(utils,ui): enhance category mapping for tickets
- Updated category mapping in utils.py to include additional categories: 'broken_streetlight', 'drainage', 'pothole', 'signage', and 'streetlight'. - Implemented a new mapping function in app.js to align backend categories with frontend display values, ensuring consistent data representation across the application. - Removed an outdated image file and added a new image file to the uploads directory.
This commit is contained in:
Binary file not shown.
@@ -99,7 +99,12 @@ def ticket_to_dict(ticket, request=None) -> dict:
|
|||||||
# Map category to expected values
|
# Map category to expected values
|
||||||
category_mapping = {
|
category_mapping = {
|
||||||
"Unknown": "other",
|
"Unknown": "other",
|
||||||
"garbage": "trash"
|
"garbage": "trash",
|
||||||
|
"broken_streetlight": "streetlight",
|
||||||
|
"drainage": "drainage",
|
||||||
|
"pothole": "pothole",
|
||||||
|
"signage": "signage",
|
||||||
|
"streetlight": "streetlight"
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 108 KiB |
BIN
backend/static/uploads/f58deb8d-d49a-4bc8-870e-e0c1d3048ab6.jpg
Normal file
BIN
backend/static/uploads/f58deb8d-d49a-4bc8-870e-e0c1d3048ab6.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
@@ -30,13 +30,28 @@ async function fetchTickets(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Map backend category names to frontend filter categories
|
||||||
|
function mapCategoryToFrontend(backendCategory) {
|
||||||
|
const categoryMapping = {
|
||||||
|
'broken_streetlight': 'streetlight', // Backend AI model category
|
||||||
|
'garbage': 'trash', // Backend AI model category
|
||||||
|
// Direct matches (backend and frontend categories are the same)
|
||||||
|
'pothole': 'pothole',
|
||||||
|
'drainage': 'drainage',
|
||||||
|
'signage': 'signage',
|
||||||
|
'streetlight': 'streetlight',
|
||||||
|
'other': 'other'
|
||||||
|
};
|
||||||
|
return categoryMapping[backendCategory] || backendCategory || 'other';
|
||||||
|
}
|
||||||
|
|
||||||
// Normalize API data to expected format
|
// Normalize API data to expected format
|
||||||
function normalizeReportData(report) {
|
function normalizeReportData(report) {
|
||||||
// Backend is already returning data in correct format
|
// Backend is already returning data in correct format
|
||||||
// Just ensure all required fields are present
|
// Just ensure all required fields are present and map categories
|
||||||
return {
|
return {
|
||||||
id: report.id,
|
id: report.id,
|
||||||
category: report.category || 'other',
|
category: mapCategoryToFrontend(report.category),
|
||||||
severity: report.severity || 'low',
|
severity: report.severity || 'low',
|
||||||
status: report.status || 'submitted',
|
status: report.status || 'submitted',
|
||||||
notes: report.notes || '',
|
notes: report.notes || '',
|
||||||
|
|||||||
Reference in New Issue
Block a user