migrated all pawprint work
This commit is contained in:
25
cfg/amar/databrowse/depot/scenarios.json
Normal file
25
cfg/amar/databrowse/depot/scenarios.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"$comment": "Test scenarios emerge from actual usage and conversations. This is just the format.",
|
||||
"scenarios": [
|
||||
{
|
||||
"_example": "This is an example scenario structure - real scenarios will be added as needed",
|
||||
"name": "Example Scenario",
|
||||
"slug": "example-scenario",
|
||||
"description": "Description of what this scenario tests",
|
||||
"role": "USER",
|
||||
"entity": "PetOwner",
|
||||
"view": "petowners_by_state",
|
||||
"filters": {
|
||||
"has_pets": true,
|
||||
"has_requests": false
|
||||
},
|
||||
"test_cases": [
|
||||
"Test case 1",
|
||||
"Test case 2"
|
||||
],
|
||||
"priority": "medium",
|
||||
"complexity": "medium",
|
||||
"notes": "Additional notes about this scenario"
|
||||
}
|
||||
]
|
||||
}
|
||||
217
cfg/amar/databrowse/depot/schema.json
Normal file
217
cfg/amar/databrowse/depot/schema.json
Normal file
@@ -0,0 +1,217 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "AMAR Data Model",
|
||||
"description": "Test-oriented data model for AMAR Mascotas. Focused on test scenarios and user navigation.",
|
||||
"version": "0.1.0",
|
||||
"meta": {
|
||||
"purpose": "Enable quick navigation to appropriate test users/scenarios",
|
||||
"modes": ["sql", "api"],
|
||||
"graph_generators": ["graphviz", "mermaid", "d3", "custom"]
|
||||
},
|
||||
"definitions": {
|
||||
"UserRole": {
|
||||
"type": "string",
|
||||
"enum": ["USER", "VET", "ADMIN"],
|
||||
"description": "User roles detected from: is_staff → ADMIN, linked to Veterinarian → VET, else USER"
|
||||
},
|
||||
"RequestState": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"pending",
|
||||
"in_progress_vet",
|
||||
"vet_asked",
|
||||
"vet_accepted",
|
||||
"in_progress_pay",
|
||||
"payed",
|
||||
"coordinated",
|
||||
"not_coordinated",
|
||||
"completed",
|
||||
"rejected"
|
||||
],
|
||||
"description": "Service request lifecycle states"
|
||||
},
|
||||
"User": {
|
||||
"type": "object",
|
||||
"description": "Django auth.User - central identity",
|
||||
"table": "auth_user",
|
||||
"properties": {
|
||||
"id": {"type": "integer", "column": "id"},
|
||||
"username": {"type": "string", "column": "username"},
|
||||
"email": {"type": "string", "column": "email"},
|
||||
"first_name": {"type": "string", "column": "first_name"},
|
||||
"last_name": {"type": "string", "column": "last_name"},
|
||||
"is_staff": {"type": "boolean", "column": "is_staff"},
|
||||
"is_active": {"type": "boolean", "column": "is_active"},
|
||||
"date_joined": {"type": "string", "format": "date-time", "column": "date_joined"}
|
||||
},
|
||||
"computed": {
|
||||
"role": {
|
||||
"description": "Derived from is_staff, veterinarian link, or default USER",
|
||||
"sql": "CASE WHEN is_staff THEN 'ADMIN' WHEN EXISTS (SELECT 1 FROM mascotas_veterinarian WHERE user_id = auth_user.id) THEN 'VET' ELSE 'USER' END"
|
||||
}
|
||||
},
|
||||
"required": ["id", "username"]
|
||||
},
|
||||
"PetOwner": {
|
||||
"type": "object",
|
||||
"description": "Pet owner (client)",
|
||||
"table": "mascotas_petowner",
|
||||
"properties": {
|
||||
"id": {"type": "integer", "column": "id"},
|
||||
"user_id": {"type": "integer", "column": "user_id"},
|
||||
"first_name": {"type": "string", "column": "first_name"},
|
||||
"last_name": {"type": "string", "column": "last_name"},
|
||||
"email": {"type": "string", "column": "email"},
|
||||
"phone": {"type": "string", "column": "phone"},
|
||||
"dni": {"type": "string", "column": "dni"},
|
||||
"address": {"type": "string", "column": "address"},
|
||||
"created_at": {"type": "string", "format": "date-time", "column": "created_at"}
|
||||
},
|
||||
"computed": {
|
||||
"has_pets": {
|
||||
"description": "Has at least one pet",
|
||||
"sql": "EXISTS (SELECT 1 FROM mascotas_pet WHERE petowner_id = mascotas_petowner.id AND deleted = false)"
|
||||
},
|
||||
"has_coverage": {
|
||||
"description": "Has active coverage",
|
||||
"sql": "EXISTS (SELECT 1 FROM mascotas_coverage WHERE petowner_id = mascotas_petowner.id AND active = true AND deleted = false)"
|
||||
},
|
||||
"has_requests": {
|
||||
"description": "Has any service requests",
|
||||
"sql": "EXISTS (SELECT 1 FROM solicitudes_servicerequest WHERE petowner_id = mascotas_petowner.id)"
|
||||
},
|
||||
"has_turnos": {
|
||||
"description": "Has scheduled turnos",
|
||||
"sql": "EXISTS (SELECT 1 FROM mascotas_vetvisit WHERE petowner_id = mascotas_petowner.id)"
|
||||
}
|
||||
},
|
||||
"required": ["id", "first_name"]
|
||||
},
|
||||
"Veterinarian": {
|
||||
"type": "object",
|
||||
"description": "Veterinarian service provider",
|
||||
"table": "mascotas_veterinarian",
|
||||
"properties": {
|
||||
"id": {"type": "integer", "column": "id"},
|
||||
"user_id": {"type": "integer", "column": "user_id"},
|
||||
"first_name": {"type": "string", "column": "first_name"},
|
||||
"last_name": {"type": "string", "column": "last_name"},
|
||||
"email": {"type": "string", "column": "email"},
|
||||
"phone": {"type": "string", "column": "phone"},
|
||||
"matricula": {"type": "string", "column": "matricula"},
|
||||
"created_at": {"type": "string", "format": "date-time", "column": "created_at"}
|
||||
},
|
||||
"computed": {
|
||||
"has_availability": {
|
||||
"description": "Has configured availability",
|
||||
"sql": "EXISTS (SELECT 1 FROM mascotas_availability WHERE veterinarian_id = mascotas_veterinarian.id AND deleted = false)"
|
||||
},
|
||||
"has_specialties": {
|
||||
"description": "Has assigned specialties",
|
||||
"sql": "EXISTS (SELECT 1 FROM mascotas_veterinarian_specialties WHERE veterinarian_id = mascotas_veterinarian.id)"
|
||||
},
|
||||
"has_coverage_areas": {
|
||||
"description": "Has coverage neighborhoods",
|
||||
"sql": "EXISTS (SELECT 1 FROM mascotas_veterinarian_neighborhoods WHERE veterinarian_id = mascotas_veterinarian.id)"
|
||||
},
|
||||
"active_requests": {
|
||||
"description": "Count of active service requests",
|
||||
"sql": "(SELECT COUNT(*) FROM solicitudes_servicerequest WHERE veterinarian_id = mascotas_veterinarian.id AND state NOT IN ('completed', 'rejected'))"
|
||||
},
|
||||
"completed_visits": {
|
||||
"description": "Count of completed visits",
|
||||
"sql": "(SELECT COUNT(*) FROM mascotas_vetvisit WHERE veterinarian_id = mascotas_veterinarian.id)"
|
||||
}
|
||||
},
|
||||
"required": ["id", "first_name"]
|
||||
},
|
||||
"Pet": {
|
||||
"type": "object",
|
||||
"description": "Pet belonging to PetOwner",
|
||||
"table": "mascotas_pet",
|
||||
"properties": {
|
||||
"id": {"type": "integer", "column": "id"},
|
||||
"petowner_id": {"type": "integer", "column": "petowner_id"},
|
||||
"name": {"type": "string", "column": "name"},
|
||||
"pet_type": {"type": "string", "column": "pet_type"},
|
||||
"breed_id": {"type": "integer", "column": "breed_id"},
|
||||
"age_years": {"type": "integer", "column": "age_years"},
|
||||
"created_at": {"type": "string", "format": "date-time", "column": "created_at"}
|
||||
},
|
||||
"computed": {
|
||||
"has_vaccines": {
|
||||
"description": "Has vaccine records",
|
||||
"sql": "EXISTS (SELECT 1 FROM mascotas_petvaccination WHERE pet_id = mascotas_pet.id)"
|
||||
},
|
||||
"has_studies": {
|
||||
"description": "Has study records",
|
||||
"sql": "EXISTS (SELECT 1 FROM mascotas_petstudy WHERE pet_id = mascotas_pet.id)"
|
||||
}
|
||||
},
|
||||
"required": ["id", "petowner_id", "name"]
|
||||
},
|
||||
"ServiceRequest": {
|
||||
"type": "object",
|
||||
"description": "Service request (order) - main workflow entity",
|
||||
"table": "solicitudes_servicerequest",
|
||||
"properties": {
|
||||
"id": {"type": "integer", "column": "id"},
|
||||
"petowner_id": {"type": "integer", "column": "petowner_id"},
|
||||
"veterinarian_id": {"type": "integer", "column": "veterinarian_id"},
|
||||
"state": {"$ref": "#/definitions/RequestState", "column": "state"},
|
||||
"pay_number": {"type": "string", "column": "pay_number"},
|
||||
"date_coordinated": {"type": "string", "format": "date", "column": "date_coordinated"},
|
||||
"hour_coordinated": {"type": "string", "format": "time", "column": "hour_coordinated"},
|
||||
"created_at": {"type": "string", "format": "date-time", "column": "created_at"}
|
||||
},
|
||||
"computed": {
|
||||
"has_cart": {
|
||||
"description": "Has associated cart",
|
||||
"sql": "EXISTS (SELECT 1 FROM productos_servicecart WHERE service_request_id = solicitudes_servicerequest.id)"
|
||||
},
|
||||
"has_payment": {
|
||||
"description": "Has payment record",
|
||||
"sql": "pay_number IS NOT NULL AND pay_number != ''"
|
||||
},
|
||||
"has_turno": {
|
||||
"description": "Has created turno",
|
||||
"sql": "EXISTS (SELECT 1 FROM mascotas_vetvisit WHERE service_request_id = solicitudes_servicerequest.id)"
|
||||
},
|
||||
"age_hours": {
|
||||
"description": "Hours since creation",
|
||||
"sql": "EXTRACT(EPOCH FROM (NOW() - created_at)) / 3600"
|
||||
}
|
||||
},
|
||||
"required": ["id", "petowner_id", "state"]
|
||||
},
|
||||
"VetVisit": {
|
||||
"type": "object",
|
||||
"description": "Scheduled veterinary visit (turno)",
|
||||
"table": "mascotas_vetvisit",
|
||||
"properties": {
|
||||
"id": {"type": "integer", "column": "id"},
|
||||
"service_request_id": {"type": "integer", "column": "service_request_id"},
|
||||
"veterinarian_id": {"type": "integer", "column": "veterinarian_id"},
|
||||
"petowner_id": {"type": "integer", "column": "petowner_id"},
|
||||
"visit_date": {"type": "string", "format": "date", "column": "visit_date"},
|
||||
"visit_hour": {"type": "string", "format": "time", "column": "visit_hour"},
|
||||
"created_at": {"type": "string", "format": "date-time", "column": "created_at"}
|
||||
},
|
||||
"computed": {
|
||||
"has_report": {
|
||||
"description": "Has post-visit report",
|
||||
"sql": "EXISTS (SELECT 1 FROM mascotas_vetvisitreport WHERE vet_visit_id = mascotas_vetvisit.id)"
|
||||
},
|
||||
"has_invoice": {
|
||||
"description": "Has generated invoice",
|
||||
"sql": "invoice_number IS NOT NULL"
|
||||
},
|
||||
"is_completed": {
|
||||
"description": "Visit has been completed",
|
||||
"sql": "visit_date < CURRENT_DATE OR (visit_date = CURRENT_DATE AND visit_hour < CURRENT_TIME)"
|
||||
}
|
||||
},
|
||||
"required": ["id", "service_request_id"]
|
||||
}
|
||||
}
|
||||
}
|
||||
178
cfg/amar/databrowse/depot/views.json
Normal file
178
cfg/amar/databrowse/depot/views.json
Normal file
@@ -0,0 +1,178 @@
|
||||
{
|
||||
"views": [
|
||||
{
|
||||
"name": "users_by_role",
|
||||
"title": "Users by Role",
|
||||
"slug": "users-by-role",
|
||||
"description": "All users grouped by role (USER/VET/ADMIN) for quick login selection",
|
||||
"mode": "sql",
|
||||
"entity": "User",
|
||||
"group_by": "role",
|
||||
"order_by": "username ASC",
|
||||
"fields": ["id", "username", "email", "first_name", "last_name", "is_staff", "is_active", "date_joined"],
|
||||
"display_fields": {
|
||||
"id": {"label": "ID", "width": "60px"},
|
||||
"username": {"label": "Username", "width": "150px", "primary": true},
|
||||
"email": {"label": "Email", "width": "200px"},
|
||||
"first_name": {"label": "First Name", "width": "120px"},
|
||||
"last_name": {"label": "Last Name", "width": "120px"},
|
||||
"is_active": {"label": "Active", "width": "80px", "type": "boolean"}
|
||||
},
|
||||
"actions": {
|
||||
"login_as": {
|
||||
"label": "Login as this user",
|
||||
"type": "command",
|
||||
"command": "echo 'Login as {{username}}' | pbcopy"
|
||||
},
|
||||
"copy_credentials": {
|
||||
"label": "Copy credentials",
|
||||
"type": "copy",
|
||||
"template": "{{username}} / Amar2025!"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "petowners_by_state",
|
||||
"title": "Pet Owners by Data State",
|
||||
"slug": "petowners-by-state",
|
||||
"description": "Pet owners grouped by data state (has_pets, has_coverage, has_requests, has_turnos)",
|
||||
"mode": "sql",
|
||||
"entity": "PetOwner",
|
||||
"group_by": "state_category",
|
||||
"order_by": "created_at DESC",
|
||||
"fields": ["id", "user_id", "first_name", "last_name", "email", "phone", "has_pets", "has_coverage", "has_requests", "has_turnos"],
|
||||
"computed_group": {
|
||||
"state_category": {
|
||||
"sql": "CASE WHEN has_turnos THEN 'with_turnos' WHEN has_requests THEN 'with_requests' WHEN has_pets THEN 'with_pets' WHEN has_coverage THEN 'with_coverage' ELSE 'new' END",
|
||||
"labels": {
|
||||
"new": "New Users (Empty)",
|
||||
"with_coverage": "With Coverage Only",
|
||||
"with_pets": "With Pets Only",
|
||||
"with_requests": "With Requests",
|
||||
"with_turnos": "With Scheduled Turnos"
|
||||
}
|
||||
}
|
||||
},
|
||||
"display_fields": {
|
||||
"id": {"label": "ID", "width": "60px"},
|
||||
"first_name": {"label": "First Name", "width": "120px"},
|
||||
"last_name": {"label": "Last Name", "width": "120px", "primary": true},
|
||||
"email": {"label": "Email", "width": "200px"},
|
||||
"phone": {"label": "Phone", "width": "120px"},
|
||||
"has_pets": {"label": "Pets", "width": "60px", "type": "icon"},
|
||||
"has_coverage": {"label": "Coverage", "width": "80px", "type": "icon"},
|
||||
"has_requests": {"label": "Requests", "width": "80px", "type": "icon"},
|
||||
"has_turnos": {"label": "Turnos", "width": "70px", "type": "icon"}
|
||||
},
|
||||
"actions": {
|
||||
"login_as": {
|
||||
"label": "Login as petowner",
|
||||
"type": "link",
|
||||
"template": "/login?user_id={{user_id}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "vets_by_availability",
|
||||
"title": "Veterinarians by Availability",
|
||||
"slug": "vets-by-availability",
|
||||
"description": "Vets grouped by availability and active work status",
|
||||
"mode": "sql",
|
||||
"entity": "Veterinarian",
|
||||
"group_by": "availability_status",
|
||||
"order_by": "active_requests DESC, completed_visits DESC",
|
||||
"fields": ["id", "user_id", "first_name", "last_name", "email", "phone", "matricula", "has_availability", "has_specialties", "has_coverage_areas", "active_requests", "completed_visits"],
|
||||
"computed_group": {
|
||||
"availability_status": {
|
||||
"sql": "CASE WHEN NOT has_availability THEN 'no_availability' WHEN active_requests > 3 THEN 'very_busy' WHEN active_requests > 0 THEN 'busy' ELSE 'available' END",
|
||||
"labels": {
|
||||
"no_availability": "No Availability Configured",
|
||||
"available": "Available (No Active Requests)",
|
||||
"busy": "Busy (1-3 Active Requests)",
|
||||
"very_busy": "Very Busy (4+ Active Requests)"
|
||||
}
|
||||
}
|
||||
},
|
||||
"display_fields": {
|
||||
"id": {"label": "ID", "width": "60px"},
|
||||
"first_name": {"label": "First Name", "width": "120px"},
|
||||
"last_name": {"label": "Last Name", "width": "120px", "primary": true},
|
||||
"matricula": {"label": "Matricula", "width": "100px"},
|
||||
"phone": {"label": "Phone", "width": "120px"},
|
||||
"has_availability": {"label": "Avail", "width": "60px", "type": "icon"},
|
||||
"has_specialties": {"label": "Spec", "width": "60px", "type": "icon"},
|
||||
"has_coverage_areas": {"label": "Areas", "width": "60px", "type": "icon"},
|
||||
"active_requests": {"label": "Active", "width": "70px", "type": "number"},
|
||||
"completed_visits": {"label": "Completed", "width": "90px", "type": "number"}
|
||||
},
|
||||
"actions": {
|
||||
"login_as": {
|
||||
"label": "Login as vet",
|
||||
"type": "link",
|
||||
"template": "/login?user_id={{user_id}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "requests_pipeline",
|
||||
"title": "Service Requests Pipeline",
|
||||
"slug": "requests-pipeline",
|
||||
"description": "Active service requests grouped by state (like turnos monitor)",
|
||||
"mode": "sql",
|
||||
"entity": "ServiceRequest",
|
||||
"group_by": "state",
|
||||
"order_by": "created_at DESC",
|
||||
"fields": ["id", "petowner_id", "veterinarian_id", "state", "pay_number", "date_coordinated", "hour_coordinated", "has_cart", "has_payment", "has_turno", "age_hours", "created_at"],
|
||||
"filter": {
|
||||
"state": ["pending", "in_progress_vet", "vet_asked", "vet_accepted", "in_progress_pay", "payed", "coordinated", "not_coordinated"]
|
||||
},
|
||||
"display_fields": {
|
||||
"id": {"label": "ID", "width": "60px", "primary": true},
|
||||
"petowner_id": {"label": "Owner", "width": "70px", "type": "link"},
|
||||
"veterinarian_id": {"label": "Vet", "width": "60px", "type": "link"},
|
||||
"state": {"label": "State", "width": "120px", "type": "badge"},
|
||||
"has_cart": {"label": "Cart", "width": "50px", "type": "icon"},
|
||||
"has_payment": {"label": "Pay", "width": "50px", "type": "icon"},
|
||||
"has_turno": {"label": "Turno", "width": "50px", "type": "icon"},
|
||||
"age_hours": {"label": "Age (h)", "width": "70px", "type": "number"}
|
||||
},
|
||||
"state_colors": {
|
||||
"pending": "#fbbf24",
|
||||
"in_progress_vet": "#f97316",
|
||||
"vet_asked": "#fb923c",
|
||||
"vet_accepted": "#4ade80",
|
||||
"in_progress_pay": "#60a5fa",
|
||||
"payed": "#2dd4bf",
|
||||
"coordinated": "#22c55e",
|
||||
"not_coordinated": "#facc15"
|
||||
},
|
||||
"actions": {
|
||||
"view_details": {
|
||||
"label": "View request",
|
||||
"type": "link",
|
||||
"template": "/admin/solicitudes/servicerequest/{{id}}/change/"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "full_graph",
|
||||
"title": "Full Data Graph",
|
||||
"slug": "full-graph",
|
||||
"description": "Complete data model graph showing all entities and relationships",
|
||||
"mode": "graph",
|
||||
"graph_type": "erd",
|
||||
"entities": ["User", "PetOwner", "Veterinarian", "Pet", "ServiceRequest", "VetVisit"],
|
||||
"relationships": [
|
||||
{"from": "User", "to": "PetOwner", "type": "1:1", "via": "user_id"},
|
||||
{"from": "User", "to": "Veterinarian", "type": "1:1", "via": "user_id"},
|
||||
{"from": "PetOwner", "to": "Pet", "type": "1:N", "via": "petowner_id"},
|
||||
{"from": "PetOwner", "to": "ServiceRequest", "type": "1:N", "via": "petowner_id"},
|
||||
{"from": "Veterinarian", "to": "ServiceRequest", "type": "1:N", "via": "veterinarian_id"},
|
||||
{"from": "ServiceRequest", "to": "VetVisit", "type": "1:1", "via": "service_request_id"},
|
||||
{"from": "Veterinarian", "to": "VetVisit", "type": "1:N", "via": "veterinarian_id"}
|
||||
},
|
||||
"layout": "hierarchical",
|
||||
"generators": ["graphviz", "mermaid", "d3"]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user