database

package
v0.0.0-...-97aba97 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PSHARPLAB    = "psharplab"
	SURVEYMONKEY = "surveymonkey"
	PAVLOVIA     = "pavlovia"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseRepository

type BaseRepository struct{}

func (*BaseRepository) GetAllBy

func (b *BaseRepository) GetAllBy(argStructSlice interface{}, query string, args ...interface{}) models.HTTPStatus

GetAllBy takes a generic struct slice and attempts to execute the given query, writing the results into the struct slice. It returns a 200, or 500 status code.

func (*BaseRepository) GetOneBy

func (b *BaseRepository) GetOneBy(argStruct interface{}, query string, args ...interface{}) models.HTTPStatus

GetOneBy takes a generic struct and attempts to execute the given query, writing the results into the struct. It returns a 200, 404, or 500 status code.

type CrowdSourcedUserRepository

type CrowdSourcedUserRepository struct{}

func (*CrowdSourcedUserRepository) CreateCrowdSourcedUser

func (c *CrowdSourcedUserRepository) CreateCrowdSourcedUser(crowdSourcedUser models.CrowdSourcedUser) models.HTTPStatus

CreateCrowdSourcedUser saves a crowdsourced user within the database. It returns a 201, 409, or 500 status code

func (*CrowdSourcedUserRepository) GetAllCrowdSourcedUsersByStudyId

func (c *CrowdSourcedUserRepository) GetAllCrowdSourcedUsersByStudyId(studyId uint) ([]models.CrowdSourcedUser, models.HTTPStatus)

GetAllCrowdSourcedUsersByStudyId retrieves all crowdsourced users for the given study id It returns a 200 or 500 status code.

func (*CrowdSourcedUserRepository) GetCrowdSourcedUserByCrowdSourcedUserAndStudyId

func (c *CrowdSourcedUserRepository) GetCrowdSourcedUserByCrowdSourcedUserAndStudyId(crowdSourcedUserId string, studyId uint) (models.CrowdSourcedUser, models.HTTPStatus)

GetCrowdSourcedUserByCrowdSourcedUserAndStudyId gets a CrowdSourcedUser by the given id. It returns a 200, 404, or 500 status code

func (*CrowdSourcedUserRepository) UpdateCrowdSourcedUser

func (c *CrowdSourcedUserRepository) UpdateCrowdSourcedUser(crowdSourcedUser models.CrowdSourcedUser) models.HTTPStatus

UpdateCrowdSourcedUser updates a crowdsourced user with the given details. It returns a 200 or 500 status code.

type OrganizationRepository

type OrganizationRepository struct{}

func (*OrganizationRepository) GetOrganizationById

func (o *OrganizationRepository) GetOrganizationById(organizationId uint) (models.Organization, models.HTTPStatus)

GetOrganizationById retrieves the given organization by id. It returns a 200, 404, or 500 status code.

type ParticipantDataRepository

type ParticipantDataRepository struct{}

func (*ParticipantDataRepository) CreateParticipantData

func (s *ParticipantDataRepository) CreateParticipantData(participantData models.ParticipantData) models.HTTPStatus

CreateParticipantData saves the given generic taskData json into the database It returns a 200, or 500 status code

func (*ParticipantDataRepository) GetAllParticipantDataByStudyIdAndTaskOrder

func (s *ParticipantDataRepository) GetAllParticipantDataByStudyIdAndTaskOrder(studyId uint, taskOrder uint) ([]models.ParticipantData, models.HTTPStatus)

GetAllParticipantDataByStudyIdAndTaskOrder gets all the participant data for the given study id and task order It returns a 200 or 500 status code

func (*ParticipantDataRepository) GetParticipantDataByStudyAndUserIdAndTaskOrder

func (s *ParticipantDataRepository) GetParticipantDataByStudyAndUserIdAndTaskOrder(studyId uint, userId string, taskOrder int) (models.ParticipantData, models.HTTPStatus)

GetParticipantDataByStudyAndUserIdAndTaskOrder gets the participant data by the given study id and task order. Crowdsourced users have user IDs stored as strings, so the userId parameter must be a string. Accountholding userIDs should be converted to strings. It returns a 200, 404, or 500 status code

type StudyRepository

type StudyRepository struct{}

func (*StudyRepository) CreateStudy

func (s *StudyRepository) CreateStudy(study *models.Study) models.HTTPStatus

CreateStudy creates a study. It returns a 201 or 500 status code.

func (*StudyRepository) GetStudiesByOrganizationId

func (s *StudyRepository) GetStudiesByOrganizationId(organizationId uint) ([]models.Study, models.HTTPStatus)

GetStudiesByOrganizationId gets all studies for the organization. It returns a 200, 404, or 500 status code.

func (*StudyRepository) GetStudyById

func (s *StudyRepository) GetStudyById(studyId uint) (models.Study, models.HTTPStatus)

GetStudyById retrieves a study from the database given the study id. It returns a 200, 404, or 500 status code.

func (*StudyRepository) UpdateStudy

func (s *StudyRepository) UpdateStudy(study *models.Study) models.HTTPStatus

UpdateStudy updates the study. It removes all study tasks from the database and updates the study with new study tasks. It returns a 200 or 500

func (*StudyRepository) UpdateStudyWithoutTaskUpdate

func (s *StudyRepository) UpdateStudyWithoutTaskUpdate(study *models.Study) models.HTTPStatus

UpdateStudyWithoutTaskUpdate updates the study. It only updates superficial fields like name, description, etc. It returns a 200 or 500 status code.

type StudyTaskRepository

type StudyTaskRepository struct{}

func (*StudyTaskRepository) CreateStudyTaskAsTransaction

func (s *StudyTaskRepository) CreateStudyTaskAsTransaction(studyTask models.StudyTask, tx *sqlx.Tx) models.HTTPStatus

CreateStudyTaskAsTransaction takes a given transaction and attempts to save studyTasks within the db, rolling back if an error is encountered. It returns a 201 or 500 status code.

func (*StudyTaskRepository) GetStudyTasksByStudyId

func (s *StudyTaskRepository) GetStudyTasksByStudyId(studyId uint) ([]models.StudyTask, models.HTTPStatus)

GetStudyTasksByStudyId retrieves all the study tasks given the study id. It returns a 200, 404, or 500 status code.

type StudyUserRepository

type StudyUserRepository struct{}

func (*StudyUserRepository) CreateStudyUser

func (s *StudyUserRepository) CreateStudyUser(studyUser *models.StudyUser) models.HTTPStatus

CreateStudyUser stores the study user in the database It returns a 201, 409, or 500 status code

func (*StudyUserRepository) GetAllStudyUsers

func (u *StudyUserRepository) GetAllStudyUsers() ([]models.DBStudyUser, models.HTTPStatus)

GetAllStudyUsers gets all study users for the database. This is used for the summary. It returns a 200 or 500 status code.

func (*StudyUserRepository) GetAllStudyUsersByStudyId

func (s *StudyUserRepository) GetAllStudyUsersByStudyId(studyId uint) ([]models.StudyUser, models.HTTPStatus)

GetAllStudyUsersByStudyId retrieves all study users associated with the given user id from the database. It returns a 200, 404, or 500 status code.

func (*StudyUserRepository) GetAllStudyUsersByUserId

func (s *StudyUserRepository) GetAllStudyUsersByUserId(userId uint) ([]models.StudyUser, models.HTTPStatus)

GetAllStudyUsersByUserId retrieves all study users associated with the given user id from the database. It returns a 200, 404, or 500 status code.

func (*StudyUserRepository) GetStudyUserByUserAndStudyId

func (s *StudyUserRepository) GetStudyUserByUserAndStudyId(userId uint, studyId uint) (models.StudyUser, models.HTTPStatus)

GetStudyUserByUserAndStudyId retrieves the study user by its associated study id and user id It returns a 200, 404, or 500 status code

func (*StudyUserRepository) UpdateStudyUser

func (s *StudyUserRepository) UpdateStudyUser(studyUser *models.StudyUser) models.HTTPStatus

UpdateStudyUser updates a study user in the db. It returns a 200 or 500 status code

type TaskRepository

type TaskRepository struct {
}

func (*TaskRepository) GetAllTasks

func (t *TaskRepository) GetAllTasks() ([]models.Task, models.HTTPStatus)

GetAllTasks retrieves all tasks from the database. It returns a 200 or 500 status code.

func (*TaskRepository) GetAllTasksByStudyId

func (t *TaskRepository) GetAllTasksByStudyId(studyId uint) ([]models.Task, models.HTTPStatus)

GetAllTasksByStudyId gets all tasks for a given study id. Currently unused. It returns a 200 or 500 status code

func (*TaskRepository) GetTaskById

func (t *TaskRepository) GetTaskById(taskID uint) (models.Task, models.HTTPStatus)

GetTaskById retrieves a task from the given id. It returns a 200, 404, or 500 status code.

type UserRepository

type UserRepository struct {
}

func (*UserRepository) CreateUser

func (u *UserRepository) CreateUser(user *models.User) (httpStatus models.HTTPStatus)

CreateUser saves a user in the database. It returns a 201, 409, or 500 status code.

func (*UserRepository) DeleteUserByID

func (u *UserRepository) DeleteUserByID(userId uint) models.HTTPStatus

DeleteUserByID deletes a user with the given Id. It returns a 200, or 500 status code

func (*UserRepository) GetUserByEmail

func (u *UserRepository) GetUserByEmail(email string) (models.User, models.HTTPStatus)

GetUserByEmail searches for a user given the email. It returns a 200, 404, or 500 status code

func (*UserRepository) GetUserById

func (u *UserRepository) GetUserById(id uint) (models.User, models.HTTPStatus)

GetUserById searches the db for a user with the given the id. It returns a 200, 404, or 500 status code.

func (*UserRepository) GetUsersByOrganizationId

func (u *UserRepository) GetUsersByOrganizationId(organizationId uint) ([]models.User, models.HTTPStatus)

GetUsersByOrganizationId retrieves all members and guests for a given organization. It returns a 200, 404, or 500 status code.

func (*UserRepository) UpdateUser

func (u *UserRepository) UpdateUser(user *models.User) (httpStatus models.HTTPStatus)

UpdateUser updates the given user in the db. It returns a 200 or 500 status code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL