func (s *StateStore) UpsertJobSummary(index uint64, jobSummary *structs.JobSummary) error {
	txn := s.db.Txn(true)
	defer txn.Abort()

	// Check if the job summary already exists
	existing, err := txn.First("job_summary", "id", jobSummary.JobID)
	if err != nil {
		return fmt.Errorf("job summary lookup failed: %v", err)
	}

	// Setup the indexes correctly
	if existing != nil {
		jobSummary.CreateIndex = existing.(*structs.JobSummary).CreateIndex
		jobSummary.ModifyIndex = index
	} else {
		jobSummary.CreateIndex = index
		jobSummary.ModifyIndex = index
	}

	// Update the index
	if err := txn.Insert("job_summary", jobSummary); err != nil {
		return err
	}

	// Update the indexes table for job summary
	if err := txn.Insert("index", &IndexEntry{"job_summary", index}); err != nil {
		return fmt.Errorf("index update failed: %v", err)
	}

	txn.Commit()
	return nil
}
// UpsertJobSummary upserts a job summary into the state store.
UpsertJobSummary upserts a job summary into the state store.
// UpsertJobSummary upserts a job summary into the state store .
func (s *StateStore) UpsertJobSummary(index uint64, jobSummary *structs.JobSummary) error {
	txn := s.db.Txn(true)
	defer txn.Abort()
	existing, err := txn.First("job_summary", "id", jobSummary.JobID)
	if err != nil {
		return fmt.Errorf("job summary lookup failed: %v", err)
	}
	if existing != nil {
		jobSummary.CreateIndex = existing.(*structs.JobSummary).CreateIndex
		jobSummary.ModifyIndex = index
	} else {
		jobSummary.CreateIndex = index
		jobSummary.ModifyIndex = index
	}
	if err := txn.Insert("job_summary", jobSummary); err != nil {
		return err
	}
	es table for job summary
	if err := txn.Insert("index", &IndexEntry{"job_summary", index}); err != nil {
		return fmt.Errorf("index update failed: %v", err)
	}
	txn.Commit()
	return nil
}
func ( s * StateStore ) UpsertJobSummary ( index uint64 , jobSummary * structs . JobSummary ) error { txn := s . db . Txn ( true ) defer txn . Abort ( ) existing , err := txn . First ( " " , " " , jobSummary . JobID ) if err != nil { return fmt . Errorf ( " " , err ) } if existing != nil { jobSummary . CreateIndex = existing . ( * structs . JobSummary ) . CreateIndex jobSummary . ModifyIndex = index } else { jobSummary . CreateIndex = index jobSummary . ModifyIndex = index } if err := txn . Insert ( " " , jobSummary ) ; err != nil { return err } if err := txn . Insert ( " " , & IndexEntry { " " , index } ) ; err != nil { return fmt . Errorf ( " " , err ) } txn . Commit ( ) return nil }
UpsertJobSummary upserts a job summary into the state store.
UpsertJobSummary upserts a job summary into the state store .
// Check if the job summary already exists // Setup the indexes correctly // Update the index // Update the indexes table for job summary