diff --git a/frontend/src/features/conversation/list/ConversationListItem.vue b/frontend/src/features/conversation/list/ConversationListItem.vue index 717170ee..aa875ab6 100644 --- a/frontend/src/features/conversation/list/ConversationListItem.vue +++ b/frontend/src/features/conversation/list/ConversationListItem.vue @@ -21,11 +21,16 @@
- +
-

- {{ contactFullName }} -

+
+

+ {{ contactFullName }} +

+ + #{{ conversation.reference_number }} + +
{{ relativeLastMessageTime }} diff --git a/internal/conversation/models/models.go b/internal/conversation/models/models.go index df4d44e7..0c564fb8 100644 --- a/internal/conversation/models/models.go +++ b/internal/conversation/models/models.go @@ -59,6 +59,7 @@ type ConversationListItem struct { CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` UUID string `db:"uuid" json:"uuid"` + ReferenceNumber string `db:"reference_number" json:"reference_number"` WaitingSince null.Time `db:"waiting_since" json:"waiting_since"` Contact ConversationListContact `db:"contact" json:"contact"` InboxChannel string `db:"inbox_channel" json:"inbox_channel"` diff --git a/internal/conversation/queries.sql b/internal/conversation/queries.sql index 665a6125..ef86b3ea 100644 --- a/internal/conversation/queries.sql +++ b/internal/conversation/queries.sql @@ -36,6 +36,7 @@ SELECT conversations.created_at, conversations.updated_at, conversations.uuid, + conversations.reference_number, conversations.waiting_since, users.created_at as "contact.created_at", users.updated_at as "contact.updated_at", diff --git a/internal/search/queries.sql b/internal/search/queries.sql index 672fd28c..08f21b07 100644 --- a/internal/search/queries.sql +++ b/internal/search/queries.sql @@ -5,19 +5,23 @@ SELECT conversations.reference_number, conversations.subject FROM conversations -WHERE reference_number::text = $1; +WHERE reference_number::text ILIKE '%' || $1 || '%' + OR subject ILIKE '%' || $1 || '%'; -- name: search-conversations-by-contact-email -SELECT +SELECT DISTINCT ON (conversations.id) conversations.created_at, conversations.uuid, conversations.reference_number, - conversations.subject + COALESCE(conversations.subject, users.first_name || ' ' || users.last_name) as subject FROM conversations JOIN users ON conversations.contact_id = users.id -WHERE users.email = $1 -ORDER BY conversations.created_at DESC -LIMIT 1000; +WHERE users.email ILIKE '%' || $1 || '%' + OR users.first_name ILIKE '%' || $1 || '%' + OR users.last_name ILIKE '%' || $1 || '%' + OR (users.first_name || ' ' || users.last_name) ILIKE '%' || $1 || '%' +ORDER BY conversations.id, conversations.created_at DESC +LIMIT 100; -- name: search-messages SELECT @@ -40,5 +44,10 @@ SELECT FROM users WHERE type = 'contact' AND deleted_at IS NULL -AND email ILIKE '%' || $1 || '%' +AND ( + email ILIKE '%' || $1 || '%' + OR first_name ILIKE '%' || $1 || '%' + OR last_name ILIKE '%' || $1 || '%' + OR (first_name || ' ' || last_name) ILIKE '%' || $1 || '%' +) LIMIT 15;