MCPcopy Index your code
hub / github.com/coder/coder / ChildChatRows

Function ChildChatRows

coderd/database/db2sdk/db2sdk.go:1955–1974  ·  view source on GitHub ↗

ChildChatRows converts child chat rows to codersdk.Chat values, resolving diff statuses from the shared map. When diffStatuses is non-nil, children without an entry receive an empty DiffStatus.

(
	children []database.GetChildChatsByParentIDsRow,
	diffStatuses map[uuid.UUID]database.ChatDiffStatus,
)

Source from the content-addressed store, hash-verified

1953// resolving diff statuses from the shared map. When diffStatuses
1954// is non-nil, children without an entry receive an empty DiffStatus.
1955func ChildChatRows(
1956 children []database.GetChildChatsByParentIDsRow,
1957 diffStatuses map[uuid.UUID]database.ChatDiffStatus,
1958) []codersdk.Chat {
1959 result := make([]codersdk.Chat, len(children))
1960 for i, row := range children {
1961 diffStatus, ok := diffStatuses[row.Chat.ID]
1962 if ok {
1963 result[i] = Chat(row.Chat, &diffStatus, nil)
1964 } else {
1965 result[i] = Chat(row.Chat, nil, nil)
1966 if diffStatuses != nil {
1967 emptyDiffStatus := ChatDiffStatus(row.Chat.ID, nil)
1968 result[i].DiffStatus = &emptyDiffStatus
1969 }
1970 }
1971 result[i].HasUnread = row.HasUnread
1972 }
1973 return result
1974}
1975
1976// ChatRowsWithChildren converts root chat rows and their child rows
1977// into codersdk.Chat values with children embedded under each parent.

Callers 2

getChatMethod · 0.92
ChatRowsWithChildrenFunction · 0.85

Calls 2

ChatFunction · 0.70
ChatDiffStatusFunction · 0.70

Tested by

no test coverage detected