func (r *GormWorkItemRepository) Load(ctx context.Context, spaceID uuid.UUID, workitemID string) (*WorkItem, error) {
	id, err := strconv.ParseUint(workitemID, 10, 64)
	if err != nil || id == 0 {
		// treating this as a not found error: the fact that we're using number internal is implementation detail
		return nil, errors.NewNotFoundError("work item", workitemID)
	}
	log.Info(nil, map[string]interface{}{
		"wi_id":    workitemID,
		"space_id": spaceID,
	}, "Loading work item")

	res := WorkItemStorage{}
	tx := r.db.Model(&res).Where("id=? AND space_id=?", id, spaceID).First(&res)
	if tx.RecordNotFound() {
		log.Error(nil, map[string]interface{}{
			"wi_id":    workitemID,
			"space_id": spaceID,
		}, "work item not found")
		tx = r.db.Model(&res).Where("id=?", id).First(&res)
		if tx.RecordNotFound() {
			log.Error(nil, map[string]interface{}{
				"wi_id":    workitemID,
				"space_id": res.SpaceID,
			}, "work item not found but found by id")
		}
		return nil, errors.NewNotFoundError("work item", workitemID)
	}
	if tx.Error != nil {
		return nil, errors.NewInternalError(tx.Error.Error())
	}
	wiType, err := r.witr.LoadTypeFromDB(ctx, res.Type)
	if err != nil {
		return nil, errors.NewInternalError(err.Error())
	}
	return ConvertWorkItemStorageToModel(wiType, &res)
}
// Load returns the work item for the given spaceID and item id
// returns NotFoundError, ConversionError or InternalError
Load returns the work item for the given spaceID and item id
returns NotFoundError, ConversionError or InternalError
// Load returns the work item for the given spaceID and item id // returns NotFoundError ConversionError or InternalError
func (r *GormWorkItemRepository) Load(ctx context.Context, spaceID uuid.UUID, workitemID string) (*WorkItem, error) {
	id, err := strconv.ParseUint(workitemID, 10, 64)
	if err != nil || id == 0 {
		return nil, errors.NewNotFoundError("work item", workitemID)
	}
	log.Info(nil, map[string]interface{}{
		"wi_id":    workitemID,
		"space_id": spaceID,
	}, "Loading work item")
	res := WorkItemStorage{}
	tx := r.db.Model(&res).Where("id=? AND space_id=?", id, spaceID).First(&res)
	if tx.RecordNotFound() {
		log.Error(nil, map[string]interface{}{
			"wi_id":    workitemID,
			"space_id": spaceID,
		}, "work item not found")
		tx = r.db.Model(&res).Where("id=?", id).First(&res)
		if tx.RecordNotFound() {
			log.Error(nil, map[string]interface{}{
				"wi_id":    workitemID,
				"space_id": res.SpaceID,
			}, "work item not found but found by id")
		}
		return nil, errors.NewNotFoundError("work item", workitemID)
	}
	if tx.Error != nil {
		return nil, errors.NewInternalError(tx.Error.Error())
	}
	wiType, err := r.witr.LoadTypeFromDB(ctx, res.Type)
	if err != nil {
		return nil, errors.NewInternalError(err.Error())
	}
	return ConvertWorkItemStorageToModel(wiType, &res)
}
func ( r * GormWorkItemRepository ) Load ( ctx context . Context , spaceID uuid . UUID , workitemID string ) ( * WorkItem , error ) { id , err := strconv . ParseUint ( workitemID , 10 , 64 ) if err != nil || id == 0 { return nil , errors . NewNotFoundError ( " " , workitemID ) } log . Info ( nil , map [ string ] interface { } { " " : workitemID , " " : spaceID , } , " " ) res := WorkItemStorage { } tx := r . db . Model ( & res ) . Where ( " " , id , spaceID ) . First ( & res ) if tx . RecordNotFound ( ) { log . Error ( nil , map [ string ] interface { } { " " : workitemID , " " : spaceID , } , " " ) tx = r . db . Model ( & res ) . Where ( " " , id ) . First ( & res ) if tx . RecordNotFound ( ) { log . Error ( nil , map [ string ] interface { } { " " : workitemID , " " : res . SpaceID , } , " " ) } return nil , errors . NewNotFoundError ( " " , workitemID ) } if tx . Error != nil { return nil , errors . NewInternalError ( tx . Error . Error ( ) ) } wiType , err := r . witr . LoadTypeFromDB ( ctx , res . Type ) if err != nil { return nil , errors . NewInternalError ( err . Error ( ) ) } return ConvertWorkItemStorageToModel ( wiType , & res ) }
Load returns the work item for the given spaceID and item id
returns NotFoundError, ConversionError or InternalError
Load returns the work item for the given spaceID and item id returns NotFoundError ConversionError or InternalError
// treating this as a not found error: the fact that we're using number internal is implementation detail