func (c *SearchController) Spaces(ctx *app.SpacesSearchContext) error {
	q := ctx.Q
	if q == "" {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrBadRequest(fmt.Errorf("Empty search query not allowed")))
	} else if q == "*" {
		q = "" // Allow empty query if * specified
	}

	var result []space.Space
	var count int
	var err error

	offset, limit := computePagingLimts(ctx.PageOffset, ctx.PageLimit)

	return application.Transactional(c.db, func(appl application.Application) error {
		var resultCount uint64
		result, resultCount, err = appl.Spaces().Search(ctx, &q, &offset, &limit)
		count = int(resultCount)
		if err != nil {
			cause := errs.Cause(err)
			switch cause.(type) {
			case errors.BadParameterError:
				return jsonapi.JSONErrorResponse(ctx, goa.ErrBadRequest(fmt.Sprintf("Error listing spaces: %s", err.Error())))
			default:
				log.Error(ctx, map[string]interface{}{
					"query":  q,
					"offset": offset,
					"limit":  limit,
					"err":    err,
				}, "unable to list spaces")
				return jsonapi.JSONErrorResponse(ctx, goa.ErrInternal(err.Error()))
			}
		}

		spaceData, err := ConvertSpacesFromModel(ctx.Context, c.db, ctx.RequestData, result)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, err)
		}
		response := app.SearchSpaceList{
			Links: &app.PagingLinks{},
			Meta:  &app.SpaceListMeta{TotalCount: count},
			Data:  spaceData,
		}
		setPagingLinks(response.Links, buildAbsoluteURL(ctx.RequestData), len(result), offset, limit, count, "q="+q)

		return ctx.OK(&response)
	})
}
// Spaces runs the space search action.
Spaces runs the space search action.
// Spaces runs the space search action .
func (c *SearchController) Spaces(ctx *app.SpacesSearchContext) error {
	q := ctx.Q
	if q == "" {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrBadRequest(fmt.Errorf("Empty search query not allowed")))
	} else if q == "*" {
		q = "" 
	}
	var result []space.Space
	var count int
	var err error
	offset, limit := computePagingLimts(ctx.PageOffset, ctx.PageLimit)
	return application.Transactional(c.db, func(appl application.Application) error {
		var resultCount uint64
		result, resultCount, err = appl.Spaces().Search(ctx, &q, &offset, &limit)
		count = int(resultCount)
		if err != nil {
			cause := errs.Cause(err)
			switch cause.(type) {
			case errors.BadParameterError:
				return jsonapi.JSONErrorResponse(ctx, goa.ErrBadRequest(fmt.Sprintf("Error listing spaces: %s", err.Error())))
			default:
				log.Error(ctx, map[string]interface{}{
					"query":  q,
					"offset": offset,
					"limit":  limit,
					"err":    err,
				}, "unable to list spaces")
				return jsonapi.JSONErrorResponse(ctx, goa.ErrInternal(err.Error()))
			}
		}
		spaceData, err := ConvertSpacesFromModel(ctx.Context, c.db, ctx.RequestData, result)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, err)
		}
		response := app.SearchSpaceList{
			Links: &app.PagingLinks{},
			Meta:  &app.SpaceListMeta{TotalCount: count},
			Data:  spaceData,
		}
		setPagingLinks(response.Links, buildAbsoluteURL(ctx.RequestData), len(result), offset, limit, count, "q="+q)
		return ctx.OK(&response)
	})
}
func ( c * SearchController ) Spaces ( ctx * app . SpacesSearchContext ) error { q := ctx . Q if q == " " { return jsonapi . JSONErrorResponse ( ctx , goa . ErrBadRequest ( fmt . Errorf ( " " ) ) ) } else if q == " " { q = " " } var result [ ] space . Space var count int var err error offset , limit := computePagingLimts ( ctx . PageOffset , ctx . PageLimit ) return application . Transactional ( c . db , func ( appl application . Application ) error { var resultCount uint64 result , resultCount , err = appl . Spaces ( ) . Search ( ctx , & q , & offset , & limit ) count = int ( resultCount ) if err != nil { cause := errs . Cause ( err ) switch cause . ( type ) { case errors . BadParameterError : return jsonapi . JSONErrorResponse ( ctx , goa . ErrBadRequest ( fmt . Sprintf ( " " , err . Error ( ) ) ) ) default : log . Error ( ctx , map [ string ] interface { } { " " : q , " " : offset , " " : limit , " " : err , } , " " ) return jsonapi . JSONErrorResponse ( ctx , goa . ErrInternal ( err . Error ( ) ) ) } } spaceData , err := ConvertSpacesFromModel ( ctx . Context , c . db , ctx . RequestData , result ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , err ) } response := app . SearchSpaceList { Links : & app . PagingLinks { } , Meta : & app . SpaceListMeta { TotalCount : count } , Data : spaceData , } setPagingLinks ( response . Links , buildAbsoluteURL ( ctx . RequestData ) , len ( result ) , offset , limit , count , " " + q ) return ctx . OK ( & response ) } ) }
Spaces runs the space search action.
Spaces runs the space search action .
// Allow empty query if * specified