func (r *GormTrackerRepository) Save(ctx context.Context, t app.Tracker) (*app.Tracker, error) {
	res := Tracker{}
	id, err := strconv.ParseUint(t.ID, 10, 64)
	if err != nil || id == 0 {
		return nil, NotFoundError{entity: "tracker", ID: t.ID}
	}

	log.Info(ctx, map[string]interface{}{
		"tracker_id": id,
	}, "Looking for a tracker repository with id ", id)

	tx := r.db.First(&res, id)
	if tx.RecordNotFound() {
		log.Error(ctx, map[string]interface{}{
			"tracker_id": id,
		}, "tracker repository not found")

		return nil, NotFoundError{entity: "tracker", ID: t.ID}
	}
	_, present := RemoteWorkItemImplRegistry[t.Type]
	// Ensure we support this remote tracker.
	if present != true {
		return nil, BadParameterError{parameter: "type", value: t.Type}
	}

	newT := Tracker{
		ID:   id,
		URL:  t.URL,
		Type: t.Type}

	if err := tx.Save(&newT).Error; err != nil {
		log.Error(ctx, map[string]interface{}{
			"tracker_id": newT.ID,
			"err":        err,
		}, "unable to save tracker repository")
		return nil, InternalError{simpleError{err.Error()}}
	}

	log.Info(ctx, map[string]interface{}{
		"tracker": newT.ID,
	}, "Tracker repository successfully updated")

	t2 := app.Tracker{
		ID:   strconv.FormatUint(id, 10),
		URL:  t.URL,
		Type: t.Type}

	return &t2, nil
}
// Save updates the given tracker in storage.
// returns NotFoundError, ConversionError or InternalError
Save updates the given tracker in storage.
returns NotFoundError, ConversionError or InternalError
// Save updates the given tracker in storage . // returns NotFoundError ConversionError or InternalError
func (r *GormTrackerRepository) Save(ctx context.Context, t app.Tracker) (*app.Tracker, error) {
	res := Tracker{}
	id, err := strconv.ParseUint(t.ID, 10, 64)
	if err != nil || id == 0 {
		return nil, NotFoundError{entity: "tracker", ID: t.ID}
	}
	log.Info(ctx, map[string]interface{}{
		"tracker_id": id,
	}, "Looking for a tracker repository with id ", id)
	tx := r.db.First(&res, id)
	if tx.RecordNotFound() {
		log.Error(ctx, map[string]interface{}{
			"tracker_id": id,
		}, "tracker repository not found")
		return nil, NotFoundError{entity: "tracker", ID: t.ID}
	}
	_, present := RemoteWorkItemImplRegistry[t.Type]
	if present != true {
		return nil, BadParameterError{parameter: "type", value: t.Type}
	}
	newT := Tracker{
		ID:   id,
		URL:  t.URL,
		Type: t.Type}
	if err := tx.Save(&newT).Error; err != nil {
		log.Error(ctx, map[string]interface{}{
			"tracker_id": newT.ID,
			"err":        err,
		}, "unable to save tracker repository")
		return nil, InternalError{simpleError{err.Error()}}
	}
	log.Info(ctx, map[string]interface{}{
		"tracker": newT.ID,
	}, "Tracker repository successfully updated")
	t2 := app.Tracker{
		ID:   strconv.FormatUint(id, 10),
		URL:  t.URL,
		Type: t.Type}
	return &t2, nil
}
func ( r * GormTrackerRepository ) Save ( ctx context . Context , t app . Tracker ) ( * app . Tracker , error ) { res := Tracker { } id , err := strconv . ParseUint ( t . ID , 10 , 64 ) if err != nil || id == 0 { return nil , NotFoundError { entity : " " , ID : t . ID } } log . Info ( ctx , map [ string ] interface { } { " " : id , } , " " , id ) tx := r . db . First ( & res , id ) if tx . RecordNotFound ( ) { log . Error ( ctx , map [ string ] interface { } { " " : id , } , " " ) return nil , NotFoundError { entity : " " , ID : t . ID } } _ , present := RemoteWorkItemImplRegistry [ t . Type ] if present != true { return nil , BadParameterError { parameter : " " , value : t . Type } } newT := Tracker { ID : id , URL : t . URL , Type : t . Type } if err := tx . Save ( & newT ) . Error ; err != nil { log . Error ( ctx , map [ string ] interface { } { " " : newT . ID , " " : err , } , " " ) return nil , InternalError { simpleError { err . Error ( ) } } } log . Info ( ctx , map [ string ] interface { } { " " : newT . ID , } , " " ) t2 := app . Tracker { ID : strconv . FormatUint ( id , 10 ) , URL : t . URL , Type : t . Type } return & t2 , nil }
Save updates the given tracker in storage.
Save updates the given tracker in storage .
// Ensure we support this remote tracker.