repository

package
v0.0.0-...-a36e7e9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRecords

func GetRecords[T any](db *gorm.DB, request *dto.RepositoryRequest) ([]T, error)

Types

type IReportRepository

type IReportRepository interface {
	GetSurveyParticipantsCount(ctx context.Context, surveyId uint) (int64, error)
	GetTotalParticipatesForSurvey(ctx context.Context, surveyId uint) (int64, error)
	GetSurveyParticipantsCountByPermissionId(ctx context.Context, surveyId uint, permissionId uint) (int64, error)
	GetTotalVotesToQuestionCount(ctx context.Context, qid uint) (int64, error)
	GetSuddenlyFinishedParticipatesForSurvey(ctx context.Context, surveyId uint) (int64, error)
	GetQuestionsBySurveyID(ctx context.Context, sid uint) ([]models.Question, error)
	GetCorrectChoiceByQuestionID(ctx context.Context, qid uint) (*models.Choice, error)
	GetChoicesByQuestionID(ctx context.Context, qid uint) ([]models.Choice, error)
	GetGivenAnswerCountByQuestionID(ctx context.Context, qid uint, answer string) (int64, error)
	GetParticipationCount(ctx context.Context, surveyId uint, userId uint) (int64, error)
	GetTotalParticipants(ctx context.Context, surveyId uint) ([]userModels.User, error)
	GetAverageResponseTime(ctx context.Context, surveyId uint) (float64, error)
	GetResponseDispersionByHour(ctx context.Context, surveyId uint) (map[int]int, error)
	GetAllSurveys(ctx context.Context) ([]models.Survey, error)
	GetAccessibleSurveys(ctx context.Context, userID uint, permission string) ([]models.Survey, error)
}

type ISurveyRepository

type ISurveyRepository interface {
	CreateSurvey(ctx context.Context, survey *models.Survey) error
	GetSurveyByID(ctx context.Context, surveyId uint) (*models.Survey, error)
	CreateQuestion(ctx context.Context, question *models.Question) error
	CreateChoice(ctx context.Context, choice *models.Choice) error
	UpdateChoice(ctx context.Context, choice *models.Choice) error
	GetChoiceByTextAndQuestion(ctx context.Context, text string, questionID uint) (*models.Choice, error)
	GetUserParticipationList(ctx context.Context, userId uint, surveyId uint) ([]models.UserSurveyParticipation, error)
	CreateUserParticipation(ctx context.Context, participation *models.UserSurveyParticipation) (*models.UserSurveyParticipation, error)
	UpdateUserParticipation(ctx context.Context, participation *models.UserSurveyParticipation) error
	GetUserParticipation(ctx context.Context, participationId uint) (*models.UserSurveyParticipation, error)
	GetLastUserParticipation(ctx context.Context, userId uint, surveyId uint) (*models.UserSurveyParticipation, error)
	CreateVote(ctx context.Context, v *models.Vote) (*models.Vote, error)
	UpdateVote(ctx context.Context, v *models.Vote) (*models.Vote, error)
	GetUserSurveyVote(ctx context.Context, user_id uint, question_id uint) (*models.Vote, error)
	UpdateQuestion(c context.Context, m *models.Question) (*models.Question, error)
	DeleteQuestion(c context.Context, id uint) error
	DeleteSurvey(c context.Context, id uint) error
	GetQuestionByID(ctx context.Context, id uint) (*models.Question, error)
	DeleteQuestionChoices(ctx context.Context, questionId uint) error
	GetQuestions(ctx context.Context, req *dto.RepositoryRequest) ([]*models.Question, error)
	GetSurveys(ctx context.Context, req *dto.RepositoryRequest) (questions []*models.Survey, err error)
	CheckVoteVisibility(surveyID, viewerID, respondentID uint) (bool, error)
	GetVotes(surveyID, respondentID uint) ([]models.Vote, error)
	GetVisibleVoteUsers(surveyID, viewerID uint) ([]map[string]interface{}, error)
	//GetResponses(ctx context.Context, userID uint, surveyID uint, privacyLevel string) ([]models.Choice, error)
	DeleteVote(c context.Context, id uint) error
	GetVoteByID(ctx context.Context, id uint) (*models.Vote, error)
	UpdateSurvey(ctx context.Context, survey *models.Survey) error
	GetSurveyVotes(ctx context.Context, id uint) ([]*models.Vote, error)

	CreateOption(ctx context.Context, option *models.SurveyOption) (*models.SurveyOption, error)
	UpdateOption(ctx context.Context, option *models.SurveyOption) error
	DeleteOption(c context.Context, id uint) error
	GetOptionByID(ctx context.Context, id uint) (*models.SurveyOption, error)
	GetOptions(ctx context.Context, req *dto.RepositoryRequest) (options []*models.SurveyOption, err error)

	SaveFile(fileName string, fileData []byte) (string, error)
}

type ReportRepository

type ReportRepository struct {
	// contains filtered or unexported fields
}

func NewReportRepository

func NewReportRepository(db db.DbService, logger logging.Logger) *ReportRepository

func (*ReportRepository) GetAccessibleSurveys

func (r *ReportRepository) GetAccessibleSurveys(ctx context.Context, userID uint, permission string) ([]models.Survey, error)

func (*ReportRepository) GetAllSurveys

func (r *ReportRepository) GetAllSurveys(ctx context.Context) ([]models.Survey, error)

func (*ReportRepository) GetAverageResponseTime

func (r *ReportRepository) GetAverageResponseTime(ctx context.Context, surveyId uint) (float64, error)

func (*ReportRepository) GetChoicesByQuestionID

func (r *ReportRepository) GetChoicesByQuestionID(ctx context.Context, qid uint) ([]models.Choice, error)

func (*ReportRepository) GetCorrectChoiceByQuestionID

func (r *ReportRepository) GetCorrectChoiceByQuestionID(ctx context.Context, qid uint) (*models.Choice, error)

func (*ReportRepository) GetGivenAnswerCount

func (r *ReportRepository) GetGivenAnswerCount(ctx context.Context, ans string) (int64, error)

func (*ReportRepository) GetGivenAnswerCountByQuestionID

func (r *ReportRepository) GetGivenAnswerCountByQuestionID(ctx context.Context, qid uint, answer string) (int64, error)

func (*ReportRepository) GetParticipationCount

func (r *ReportRepository) GetParticipationCount(ctx context.Context, surveyId uint, userId uint) (int64, error)

func (*ReportRepository) GetQuestionsBySurveyID

func (r *ReportRepository) GetQuestionsBySurveyID(ctx context.Context, sid uint) ([]models.Question, error)

func (*ReportRepository) GetResponseDispersionByHour

func (r *ReportRepository) GetResponseDispersionByHour(ctx context.Context, surveyId uint) (map[int]int, error)

func (*ReportRepository) GetSuddenlyFinishedParticipatesForSurvey

func (r *ReportRepository) GetSuddenlyFinishedParticipatesForSurvey(ctx context.Context, surveyId uint) (int64, error)

func (*ReportRepository) GetSurveyParticipantsCount

func (r *ReportRepository) GetSurveyParticipantsCount(ctx context.Context, surveyId uint) (int64, error)

func (*ReportRepository) GetSurveyParticipantsCountByPermissionId

func (r *ReportRepository) GetSurveyParticipantsCountByPermissionId(ctx context.Context, surveyId uint, permissionId uint) (int64, error)

func (*ReportRepository) GetTotalParticipants

func (r *ReportRepository) GetTotalParticipants(ctx context.Context, surveyId uint) ([]userModels.User, error)

func (*ReportRepository) GetTotalParticipatesForSurvey

func (r *ReportRepository) GetTotalParticipatesForSurvey(ctx context.Context, surveyId uint) (int64, error)

func (*ReportRepository) GetTotalVotesToQuestionCount

func (r *ReportRepository) GetTotalVotesToQuestionCount(ctx context.Context, qid uint) (int64, error)

type SurveyRepository

type SurveyRepository struct {
	// contains filtered or unexported fields
}

func NewSurveyRepository

func NewSurveyRepository(db db.DbService, logger logging.Logger) *SurveyRepository

func (*SurveyRepository) CheckVoteVisibility

func (r *SurveyRepository) CheckVoteVisibility(surveyID, viewerID, respondentID uint) (bool, error)

func (*SurveyRepository) CreateChoice

func (r *SurveyRepository) CreateChoice(ctx context.Context, choice *models.Choice) error

func (*SurveyRepository) CreateOption

func (r *SurveyRepository) CreateOption(ctx context.Context, option *models.SurveyOption) (*models.SurveyOption, error)

func (*SurveyRepository) CreateQuestion

func (r *SurveyRepository) CreateQuestion(ctx context.Context, question *models.Question) error

func (*SurveyRepository) CreateSurvey

func (r *SurveyRepository) CreateSurvey(ctx context.Context, survey *models.Survey) error

func (*SurveyRepository) CreateUserParticipation

func (r *SurveyRepository) CreateUserParticipation(ctx context.Context, participation *models.UserSurveyParticipation) (*models.UserSurveyParticipation, error)

func (*SurveyRepository) CreateVote

func (r *SurveyRepository) CreateVote(ctx context.Context, v *models.Vote) (*models.Vote, error)

func (*SurveyRepository) DeleteOption

func (r *SurveyRepository) DeleteOption(c context.Context, id uint) error

func (*SurveyRepository) DeleteQuestion

func (q *SurveyRepository) DeleteQuestion(c context.Context, id uint) error

func (*SurveyRepository) DeleteQuestionChoices

func (r *SurveyRepository) DeleteQuestionChoices(c context.Context, questionId uint) error

func (*SurveyRepository) DeleteSurvey

func (q *SurveyRepository) DeleteSurvey(c context.Context, id uint) error

func (*SurveyRepository) DeleteVote

func (q *SurveyRepository) DeleteVote(c context.Context, id uint) error

func (*SurveyRepository) GetChoiceByTextAndQuestion

func (r *SurveyRepository) GetChoiceByTextAndQuestion(ctx context.Context, text string, questionID uint) (*models.Choice, error)

func (*SurveyRepository) GetLastUserParticipation

func (r *SurveyRepository) GetLastUserParticipation(ctx context.Context, userId uint, surveyId uint) (*models.UserSurveyParticipation, error)

func (*SurveyRepository) GetOptionByID

func (r *SurveyRepository) GetOptionByID(ctx context.Context, id uint) (option *models.SurveyOption, err error)

func (*SurveyRepository) GetOptions

func (r *SurveyRepository) GetOptions(ctx context.Context, req *dto.RepositoryRequest) (options []*models.SurveyOption, err error)

func (*SurveyRepository) GetQuestionByID

func (r *SurveyRepository) GetQuestionByID(ctx context.Context, id uint) (*models.Question, error)

func (*SurveyRepository) GetQuestions

func (r *SurveyRepository) GetQuestions(ctx context.Context, req *dto.RepositoryRequest) (questions []*models.Question, err error)

func (*SurveyRepository) GetSurveyByID

func (r *SurveyRepository) GetSurveyByID(ctx context.Context, surveyId uint) (*models.Survey, error)

func (*SurveyRepository) GetSurveyVotes

func (r *SurveyRepository) GetSurveyVotes(ctx context.Context, id uint) ([]*models.Vote, error)

func (*SurveyRepository) GetSurveys

func (r *SurveyRepository) GetSurveys(ctx context.Context, req *dto.RepositoryRequest) (questions []*models.Survey, err error)

func (*SurveyRepository) GetUserParticipation

func (r *SurveyRepository) GetUserParticipation(ctx context.Context, participationId uint) (*models.UserSurveyParticipation, error)

func (*SurveyRepository) GetUserParticipationList

func (r *SurveyRepository) GetUserParticipationList(ctx context.Context, userId uint, surveyId uint) ([]models.UserSurveyParticipation, error)

func (*SurveyRepository) GetUserSurveyVote

func (r *SurveyRepository) GetUserSurveyVote(ctx context.Context, user_id uint, question_id uint) (*models.Vote, error)

func (*SurveyRepository) GetVisibleVoteUsers

func (r *SurveyRepository) GetVisibleVoteUsers(surveyID, viewerID uint) ([]map[string]interface{}, error)

func (*SurveyRepository) GetVoteByID

func (r *SurveyRepository) GetVoteByID(ctx context.Context, id uint) (*models.Vote, error)

func (*SurveyRepository) GetVotes

func (r *SurveyRepository) GetVotes(surveyID, respondentID uint) ([]models.Vote, error)

func (*SurveyRepository) SaveFile

func (r *SurveyRepository) SaveFile(fileName string, fileData []byte) (string, error)

func (*SurveyRepository) UpdateChoice

func (r *SurveyRepository) UpdateChoice(ctx context.Context, choice *models.Choice) error

func (*SurveyRepository) UpdateOption

func (r *SurveyRepository) UpdateOption(ctx context.Context, option *models.SurveyOption) error

func (*SurveyRepository) UpdateQuestion

func (q *SurveyRepository) UpdateQuestion(c context.Context, m *models.Question) (*models.Question, error)

func (*SurveyRepository) UpdateSurvey

func (r *SurveyRepository) UpdateSurvey(ctx context.Context, survey *models.Survey) error

func (*SurveyRepository) UpdateUserParticipation

func (r *SurveyRepository) UpdateUserParticipation(ctx context.Context, participation *models.UserSurveyParticipation) error

func (*SurveyRepository) UpdateVote

func (r *SurveyRepository) UpdateVote(ctx context.Context, v *models.Vote) (*models.Vote, error)

Jump to

Keyboard shortcuts

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