@startuml
title Email Admin List Totals (After)

skinparam backgroundColor #FFFFFF
skinparam defaultFontColor #000000
skinparam ArrowColor #000000
skinparam SequenceLifeLineBorderColor #000000
skinparam SequenceLifeLineBackgroundColor #F7F7F7
skinparam ParticipantBorderColor #000000
skinparam ParticipantBackgroundColor #DFF3FF
skinparam NoteBackgroundColor #E8FCE8
skinparam NoteBorderColor #000000

actor "Admin Client" as Client
participant "AdminPlugin\n(list handlers)" as Handler
participant "Tenant Runtime\nDatabaseAdapter" as Adapter
database "Tenant Email Tables\n(emails / failures / templates)" as Tables

Client -> Handler: GET /admin/email*/list\n(limit=1, filters...)
Handler -> Adapter: count_*(filters)\n(ignore limit/offset)
Adapter -> Tables: SELECT COUNT(*) ... WHERE filters
Tables --> Adapter: total = N
Adapter --> Handler: N

Handler -> Adapter: list_*(limit=1, offset=0, filters)
Adapter -> Tables: SELECT ... WHERE filters\nORDER BY ... LIMIT 1 OFFSET 0
Tables --> Adapter: page rows (size = 1)
Adapter --> Handler: Vec<row>(len = 1)

Handler --> Client: { total: N, items: [ ...1 row... ] }

note right of Handler
`total` is accurate across all
matching rows per tenant runtime.
end note

@enduml
