func (c *WorkitemController) List(ctx *app.ListWorkitemContext) error {
	spaceID, err := uuid.FromString(ctx.ID)
	if err != nil {
		return errors.NewNotFoundError("spaceID", ctx.ID)
	}

	var additionalQuery []string
	exp, err := query.Parse(ctx.Filter)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("could not parse filter", err))
	}
	if ctx.FilterAssignee != nil {
		exp = criteria.And(exp, criteria.Equals(criteria.Field("system.assignees"), criteria.Literal([]string{*ctx.FilterAssignee})))
		additionalQuery = append(additionalQuery, "filter[assignee]="+*ctx.FilterAssignee)
	}
	if ctx.FilterIteration != nil {
		exp = criteria.And(exp, criteria.Equals(criteria.Field(workitem.SystemIteration), criteria.Literal(string(*ctx.FilterIteration))))
		additionalQuery = append(additionalQuery, "filter[iteration]="+*ctx.FilterIteration)
		// Update filter by adding child iterations if any
		application.Transactional(c.db, func(tx application.Application) error {
			iterationUUID, errConversion := uuid.FromString(*ctx.FilterIteration)
			if errConversion != nil {
				return jsonapi.JSONErrorResponse(ctx, errs.Wrap(errConversion, "Invalid iteration ID"))
			}
			childrens, err := tx.Iterations().LoadChildren(ctx.Context, iterationUUID)
			if err != nil {
				return jsonapi.JSONErrorResponse(ctx, errs.Wrap(err, "Unable to fetch children"))
			}
			for _, child := range childrens {
				childIDStr := child.ID.String()
				exp = criteria.Or(exp, criteria.Equals(criteria.Field(workitem.SystemIteration), criteria.Literal(childIDStr)))
				additionalQuery = append(additionalQuery, "filter[iteration]="+childIDStr)
			}
			return nil
		})
	}
	if ctx.FilterWorkitemtype != nil {
		exp = criteria.And(exp, criteria.Equals(criteria.Field("Type"), criteria.Literal([]uuid.UUID{*ctx.FilterWorkitemtype})))
		additionalQuery = append(additionalQuery, "filter[workitemtype]="+ctx.FilterWorkitemtype.String())
	}
	if ctx.FilterArea != nil {
		exp = criteria.And(exp, criteria.Equals(criteria.Field(workitem.SystemArea), criteria.Literal(string(*ctx.FilterArea))))
		additionalQuery = append(additionalQuery, "filter[area]="+*ctx.FilterArea)
	}
	if ctx.FilterWorkitemstate != nil {
		exp = criteria.And(exp, criteria.Equals(criteria.Field(workitem.SystemState), criteria.Literal(string(*ctx.FilterWorkitemstate))))
		additionalQuery = append(additionalQuery, "filter[workitemstate]="+*ctx.FilterWorkitemstate)
	}

	offset, limit := computePagingLimts(ctx.PageOffset, ctx.PageLimit)
	return application.Transactional(c.db, func(tx application.Application) error {
		workitems, tc, err := tx.WorkItems().List(ctx.Context, spaceID, exp, &offset, &limit)
		count := int(tc)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, errs.Wrap(err, "Error listing work items"))
		}
		return ctx.ConditionalEntities(workitems, c.config.GetCacheControlWorkItems, func() error {
			response := app.WorkItemList{
				Links: &app.PagingLinks{},
				Meta:  &app.WorkItemListResponseMeta{TotalCount: count},
				Data:  ConvertWorkItems(ctx.RequestData, workitems),
			}
			setPagingLinks(response.Links, buildAbsoluteURL(ctx.RequestData), len(workitems), offset, limit, count, additionalQuery...)
			addFilterLinks(response.Links, ctx.RequestData)
			return ctx.OK(&response)
		})

	})
}
// List runs the list action.
// Prev and Next links will be present only when there actually IS a next or previous page.
// Last will always be present. Total Item count needs to be computed from the "Last" link.
List runs the list action.
Prev and Next links will be present only when there actually IS a next or previous page.
Last will always be present. Total Item count needs to be computed from the "Last" link.
// List runs the list action . // Prev and Next links will be present only when there actually IS a next or previous page . // Last will always be present . Total Item count needs to be computed from the " Last " link .
func (c *WorkitemController) List(ctx *app.ListWorkitemContext) error {
	spaceID, err := uuid.FromString(ctx.ID)
	if err != nil {
		return errors.NewNotFoundError("spaceID", ctx.ID)
	}
	var additionalQuery []string
	exp, err := query.Parse(ctx.Filter)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("could not parse filter", err))
	}
	if ctx.FilterAssignee != nil {
		exp = criteria.And(exp, criteria.Equals(criteria.Field("system.assignees"), criteria.Literal([]string{*ctx.FilterAssignee})))
		additionalQuery = append(additionalQuery, "filter[assignee]="+*ctx.FilterAssignee)
	}
	if ctx.FilterIteration != nil {
		exp = criteria.And(exp, criteria.Equals(criteria.Field(workitem.SystemIteration), criteria.Literal(string(*ctx.FilterIteration))))
		additionalQuery = append(additionalQuery, "filter[iteration]="+*ctx.FilterIteration)
		application.Transactional(c.db, func(tx application.Application) error {
			iterationUUID, errConversion := uuid.FromString(*ctx.FilterIteration)
			if errConversion != nil {
				return jsonapi.JSONErrorResponse(ctx, errs.Wrap(errConversion, "Invalid iteration ID"))
			}
			childrens, err := tx.Iterations().LoadChildren(ctx.Context, iterationUUID)
			if err != nil {
				return jsonapi.JSONErrorResponse(ctx, errs.Wrap(err, "Unable to fetch children"))
			}
			for _, child := range childrens {
				childIDStr := child.ID.String()
				exp = criteria.Or(exp, criteria.Equals(criteria.Field(workitem.SystemIteration), criteria.Literal(childIDStr)))
				additionalQuery = append(additionalQuery, "filter[iteration]="+childIDStr)
			}
			return nil
		})
	}
	if ctx.FilterWorkitemtype != nil {
		exp = criteria.And(exp, criteria.Equals(criteria.Field("Type"), criteria.Literal([]uuid.UUID{*ctx.FilterWorkitemtype})))
		additionalQuery = append(additionalQuery, "filter[workitemtype]="+ctx.FilterWorkitemtype.String())
	}
	if ctx.FilterArea != nil {
		exp = criteria.And(exp, criteria.Equals(criteria.Field(workitem.SystemArea), criteria.Literal(string(*ctx.FilterArea))))
		additionalQuery = append(additionalQuery, "filter[area]="+*ctx.FilterArea)
	}
	if ctx.FilterWorkitemstate != nil {
		exp = criteria.And(exp, criteria.Equals(criteria.Field(workitem.SystemState), criteria.Literal(string(*ctx.FilterWorkitemstate))))
		additionalQuery = append(additionalQuery, "filter[workitemstate]="+*ctx.FilterWorkitemstate)
	}
	offset, limit := computePagingLimts(ctx.PageOffset, ctx.PageLimit)
	return application.Transactional(c.db, func(tx application.Application) error {
		workitems, tc, err := tx.WorkItems().List(ctx.Context, spaceID, exp, &offset, &limit)
		count := int(tc)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, errs.Wrap(err, "Error listing work items"))
		}
		return ctx.ConditionalEntities(workitems, c.config.GetCacheControlWorkItems, func() error {
			response := app.WorkItemList{
				Links: &app.PagingLinks{},
				Meta:  &app.WorkItemListResponseMeta{TotalCount: count},
				Data:  ConvertWorkItems(ctx.RequestData, workitems),
			}
			setPagingLinks(response.Links, buildAbsoluteURL(ctx.RequestData), len(workitems), offset, limit, count, additionalQuery...)
			addFilterLinks(response.Links, ctx.RequestData)
			return ctx.OK(&response)
		})
	})
}
func ( c * WorkitemController ) List ( ctx * app . ListWorkitemContext ) error { spaceID , err := uuid . FromString ( ctx . ID ) if err != nil { return errors . NewNotFoundError ( " " , ctx . ID ) } var additionalQuery [ ] string exp , err := query . Parse ( ctx . Filter ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , errors . NewBadParameterError ( " " , err ) ) } if ctx . FilterAssignee != nil { exp = criteria . And ( exp , criteria . Equals ( criteria . Field ( " " ) , criteria . Literal ( [ ] string { * ctx . FilterAssignee } ) ) ) additionalQuery = append ( additionalQuery , " " + * ctx . FilterAssignee ) } if ctx . FilterIteration != nil { exp = criteria . And ( exp , criteria . Equals ( criteria . Field ( workitem . SystemIteration ) , criteria . Literal ( string ( * ctx . FilterIteration ) ) ) ) additionalQuery = append ( additionalQuery , " " + * ctx . FilterIteration ) application . Transactional ( c . db , func ( tx application . Application ) error { iterationUUID , errConversion := uuid . FromString ( * ctx . FilterIteration ) if errConversion != nil { return jsonapi . JSONErrorResponse ( ctx , errs . Wrap ( errConversion , " " ) ) } childrens , err := tx . Iterations ( ) . LoadChildren ( ctx . Context , iterationUUID ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , errs . Wrap ( err , " " ) ) } for _ , child := range childrens { childIDStr := child . ID . String ( ) exp = criteria . Or ( exp , criteria . Equals ( criteria . Field ( workitem . SystemIteration ) , criteria . Literal ( childIDStr ) ) ) additionalQuery = append ( additionalQuery , " " + childIDStr ) } return nil } ) } if ctx . FilterWorkitemtype != nil { exp = criteria . And ( exp , criteria . Equals ( criteria . Field ( " " ) , criteria . Literal ( [ ] uuid . UUID { * ctx . FilterWorkitemtype } ) ) ) additionalQuery = append ( additionalQuery , " " + ctx . FilterWorkitemtype . String ( ) ) } if ctx . FilterArea != nil { exp = criteria . And ( exp , criteria . Equals ( criteria . Field ( workitem . SystemArea ) , criteria . Literal ( string ( * ctx . FilterArea ) ) ) ) additionalQuery = append ( additionalQuery , " " + * ctx . FilterArea ) } if ctx . FilterWorkitemstate != nil { exp = criteria . And ( exp , criteria . Equals ( criteria . Field ( workitem . SystemState ) , criteria . Literal ( string ( * ctx . FilterWorkitemstate ) ) ) ) additionalQuery = append ( additionalQuery , " " + * ctx . FilterWorkitemstate ) } offset , limit := computePagingLimts ( ctx . PageOffset , ctx . PageLimit ) return application . Transactional ( c . db , func ( tx application . Application ) error { workitems , tc , err := tx . WorkItems ( ) . List ( ctx . Context , spaceID , exp , & offset , & limit ) count := int ( tc ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , errs . Wrap ( err , " " ) ) } return ctx . ConditionalEntities ( workitems , c . config . GetCacheControlWorkItems , func ( ) error { response := app . WorkItemList { Links : & app . PagingLinks { } , Meta : & app . WorkItemListResponseMeta { TotalCount : count } , Data : ConvertWorkItems ( ctx . RequestData , workitems ) , } setPagingLinks ( response . Links , buildAbsoluteURL ( ctx . RequestData ) , len ( workitems ) , offset , limit , count , additionalQuery ... ) addFilterLinks ( response . Links , ctx . RequestData ) return ctx . OK ( & response ) } ) } ) }
List runs the list action.
List runs the list action .
// Update filter by adding child iterations if any