func FindOneProcessRuntime(query interface{},
	projection interface{}) (*ProcessRuntime, error) {
	runtime := &ProcessRuntime{}
	err := db.FindOne(
		RuntimesCollection,
		query,
		projection,
		db.NoSort,
		runtime,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return runtime, err
}
Exemple #2
0
func FindOneTask(query interface{}, projection interface{},
	sort []string) (*Task, error) {
	task := &Task{}
	err := db.FindOne(
		TasksCollection,
		query,
		projection,
		sort,
		task,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return task, err
}
Exemple #3
0
func FindOnePushLog(query interface{}, projection interface{},
	sort []string) (*PushLog, error) {
	pushLog := &PushLog{}
	err := db.FindOne(
		PushlogCollection,
		query,
		projection,
		sort,
		pushLog,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return pushLog, err
}
func FindOneNotification(query interface{},
	projection interface{}) (*NotificationHistory, error) {
	notificationHistory := &NotificationHistory{}
	err := db.FindOne(
		NotifyHistoryCollection,
		query,
		projection,
		db.NoSort,
		notificationHistory,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return notificationHistory, err
}
Exemple #5
0
func FindOneTestLogById(id string) (*TestLog, error) {
	tl := &TestLog{}
	err := db.FindOne(
		TestLogCollection,
		bson.M{
			TestLogIdKey: id,
		},
		db.NoProjection,
		db.NoSort,
		tl,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return tl, err
}
Exemple #6
0
// FindOneProjectRef gets a project ref given the owner name, the repo
// name and the project name
func FindOneProjectRef(identifier string) (*ProjectRef, error) {
	projectRef := &ProjectRef{}
	err := db.FindOne(
		ProjectRefCollection,
		bson.M{
			ProjectRefIdentifierKey: identifier,
		},
		db.NoProjection,
		db.NoSort,
		projectRef,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return projectRef, err
}
Exemple #7
0
// FindRepository gets the repository object of a project.
func FindRepository(projectId string) (*Repository, error) {
	repository := &Repository{}
	err := db.FindOne(
		RepositoriesCollection,
		bson.M{
			RepoProjectKey: projectId,
		},
		db.NoProjection,
		db.NoSort,
		repository,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return repository, err
}
Exemple #8
0
func FindTaskQueueForDistro(distroId string) (*TaskQueue, error) {
	taskQueue := &TaskQueue{}
	err := db.FindOne(
		TaskQueuesCollection,
		bson.M{
			TaskQueueDistroKey: distroId,
		},
		db.NoProjection,
		db.NoSort,
		taskQueue,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return taskQueue, err
}
Exemple #9
0
// FindOneTestLog returns a TestLog, given the test's name, task id,
// and execution.
func FindOneTestLog(name, task string, execution int) (*TestLog, error) {
	tl := &TestLog{}
	err := db.FindOne(
		TestLogCollection,
		bson.M{
			TestLogNameKey:          name,
			TestLogTaskKey:          task,
			TestLogTaskExecutionKey: execution,
		},
		db.NoProjection,
		db.NoSort,
		tl,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return tl, err
}
Exemple #10
0
func FindOneProjectVars(projectId string) (*ProjectVars, error) {
	projectVars := &ProjectVars{}
	err := db.FindOne(
		ProjectVarsCollection,
		bson.M{
			ProjectVarIdKey: projectId,
		},
		db.NoProjection,
		db.NoSort,
		projectVars,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	if err != nil {
		return nil, err
	}
	return projectVars, nil
}
Exemple #11
0
func LastNotificationsEventTime(projectName string) (time.Time,
	error) {

	nAnswers, err := db.Count(
		NotifyTimesCollection,
		bson.M{
			PntProjectNameKey: projectName,
		},
	)

	if err != nil {
		return EarliestDateToConsider, err
	}
	if nAnswers == 0 {
		return EarliestDateToConsider, nil
	}

	if nAnswers > 1 {
		return EarliestDateToConsider, fmt.Errorf("There are %v notification"+
			" times listed for having seen the NOTIFICATION_REPOSITORY “%v”;"+
			" there should be at most one.", nAnswers, projectName)
	}

	event := &ProjectNotificationTime{}
	err = db.FindOne(
		NotifyTimesCollection,
		bson.M{
			PntProjectNameKey: projectName,
		},
		db.NoProjection,
		db.NoSort,
		event,
	)
	if err != nil {
		return EarliestDateToConsider, err
	}
	if err == mgo.ErrNotFound {
		return EarliestDateToConsider, nil
	}

	return event.LastNotificationEventTime, nil
}
Exemple #12
0
func FindOneOldTask(query interface{}, projection interface{},
	sort []string) (*Task, error) {
	task := &Task{}
	err := db.FindOne(
		OldTasksCollection,
		query,
		projection,
		sort,
		task,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	if task != nil {
		task.Id = task.OldTaskId
	}
	if task.Id == "" {
		return nil, fmt.Errorf("old task had nil id")
	}
	return task, err
}