func WorkItemIncludeCommentsAndTotal(ctx context.Context, db application.DB, parentID string) WorkItemConvertFunc {
	// TODO: Wrap ctx in a Timeout context?
	count := make(chan int)
	go func() {
		defer close(count)
		application.Transactional(db, func(appl application.Application) error {
			cs, err := appl.Comments().Count(ctx, parentID)
			if err != nil {
				count <- 0
				return errors.WithStack(err)
			}
			count <- cs
			return nil
		})
	}()
	return func(request *goa.RequestData, wi *workitem.WorkItem, wi2 *app.WorkItem) {
		wi2.Relationships.Comments = CreateCommentsRelation(request, wi)
		wi2.Relationships.Comments.Meta = map[string]interface{}{
			"totalCount": <-count,
		}
	}
}
// WorkItemIncludeCommentsAndTotal adds relationship about comments to workitem (include totalCount)
WorkItemIncludeCommentsAndTotal adds relationship about comments to workitem (include totalCount)
// WorkItemIncludeCommentsAndTotal adds relationship about comments to workitem ( include totalCount )
func WorkItemIncludeCommentsAndTotal(ctx context.Context, db application.DB, parentID string) WorkItemConvertFunc {
	count := make(chan int)
	go func() {
		defer close(count)
		application.Transactional(db, func(appl application.Application) error {
			cs, err := appl.Comments().Count(ctx, parentID)
			if err != nil {
				count <- 0
				return errors.WithStack(err)
			}
			count <- cs
			return nil
		})
	}()
	return func(request *goa.RequestData, wi *workitem.WorkItem, wi2 *app.WorkItem) {
		wi2.Relationships.Comments = CreateCommentsRelation(request, wi)
		wi2.Relationships.Comments.Meta = map[string]interface{}{
			"totalCount": <-count,
		}
	}
}
func WorkItemIncludeCommentsAndTotal ( ctx context . Context , db application . DB , parentID string ) WorkItemConvertFunc { count := make ( chan int ) go func ( ) { defer close ( count ) application . Transactional ( db , func ( appl application . Application ) error { cs , err := appl . Comments ( ) . Count ( ctx , parentID ) if err != nil { count <- 0 return errors . WithStack ( err ) } count <- cs return nil } ) } ( ) return func ( request * goa . RequestData , wi * workitem . WorkItem , wi2 * app . WorkItem ) { wi2 . Relationships . Comments = CreateCommentsRelation ( request , wi ) wi2 . Relationships . Comments . Meta = map [ string ] interface { } { " " : <- count , } } }
WorkItemIncludeCommentsAndTotal adds relationship about comments to workitem (include totalCount)
WorkItemIncludeCommentsAndTotal adds relationship about comments to workitem ( include totalCount )
// TODO: Wrap ctx in a Timeout context?