db

package
v0.0.0-...-d695403 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const PollId = "1"

PollId there can be only one

View Source
const TestEventSourceValid = "github"

TestEventSourceValid EventSource is lower case to match case sent by loggly

View Source
const TestOrgValid = "myValidTestOrganization"

Variables

This section is empty.

Functions

func NewPoll

func NewPoll() types.Poll

func PollConvertSqlToDbMockExpect

func PollConvertSqlToDbMockExpect(realSql string) string

PollConvertSqlToDbMockExpect exposed for poll package tests

func SetupMockPollSelect

func SetupMockPollSelect(mock sqlmock.Sqlmock, pollId string, now time.Time)

func SetupMockPollSelectAndUpdate

func SetupMockPollSelectAndUpdate(mock sqlmock.Sqlmock, pollId string, now time.Time, rowsAffected int64)

func SetupMockPollSelectAndUpdateAnyUpdateTime

func SetupMockPollSelectAndUpdateAnyUpdateTime(mock sqlmock.Sqlmock, pollId string, now time.Time, rowsAffected int64)

func SetupMockPollSelectForcedError

func SetupMockPollSelectForcedError(mock sqlmock.Sqlmock, forcedError error, pollId string)

Types

type BBashDB

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

func New

func New(db *sql.DB, logger *zap.Logger) *BBashDB

func SetupMockDB

func SetupMockDB(t *testing.T) (mock sqlmock.Sqlmock, mockDbIf *BBashDB, closeDbFunc func())

SetupMockDB should always be followed by a call to the closeDbFunc, like so:

mock, db, closeDbFunc := SetupMockDB(t)
defer closeDbFunc()

func (*BBashDB) DeleteOrganization

func (p *BBashDB) DeleteOrganization(scpName, orgName string) (rowsAffected int64, err error)

func (*BBashDB) DeleteParticipant

func (p *BBashDB) DeleteParticipant(campaign, scpName, loginName string) (participantId string, err error)

func (*BBashDB) GetActiveCampaigns

func (p *BBashDB) GetActiveCampaigns(now time.Time) (activeCampaigns []types.CampaignStruct, err error)

func (*BBashDB) GetCampaign

func (p *BBashDB) GetCampaign(campaignName string) (campaign *types.CampaignStruct, err error)

func (*BBashDB) GetCampaigns

func (p *BBashDB) GetCampaigns() (campaigns []types.CampaignStruct, err error)

func (*BBashDB) GetDb

func (p *BBashDB) GetDb() (db *sql.DB)

func (*BBashDB) GetOrganizations

func (p *BBashDB) GetOrganizations() (organizations []types.OrganizationStruct, err error)

func (*BBashDB) GetSourceControlProviders

func (p *BBashDB) GetSourceControlProviders() (scps []types.SourceControlProviderStruct, err error)

func (*BBashDB) InsertBug

func (p *BBashDB) InsertBug(bug *types.BugStruct) (err error)

func (*BBashDB) InsertCampaign

func (p *BBashDB) InsertCampaign(campaign *types.CampaignStruct) (guid string, err error)

func (*BBashDB) InsertOrganization

func (p *BBashDB) InsertOrganization(organization *types.OrganizationStruct) (guid string, err error)

func (*BBashDB) InsertParticipant

func (p *BBashDB) InsertParticipant(participant *types.ParticipantStruct) (err error)

func (*BBashDB) InsertScoringEvent

func (p *BBashDB) InsertScoringEvent(participantToScore *types.ParticipantStruct, msg *types.ScoringMessage, newPoints float64) (err error)

func (*BBashDB) InsertTeam

func (p *BBashDB) InsertTeam(team *types.TeamStruct) (err error)

func (*BBashDB) MigrateDB

func (p *BBashDB) MigrateDB(migrateSourceURL string) (err error)

func (*BBashDB) SelectBugs

func (p *BBashDB) SelectBugs() (bugs []types.BugStruct, err error)

func (*BBashDB) SelectParticipantDetail

func (p *BBashDB) SelectParticipantDetail(campaignName, scpName, loginName string) (participant *types.ParticipantStruct, err error)

func (*BBashDB) SelectParticipantsInCampaign

func (p *BBashDB) SelectParticipantsInCampaign(campaignName string) (participants []types.ParticipantStruct, err error)

func (*BBashDB) SelectParticipantsToScore

func (p *BBashDB) SelectParticipantsToScore(msg *types.ScoringMessage, now time.Time) (participantsToScore []types.ParticipantStruct, err error)

func (*BBashDB) SelectPointValue

func (p *BBashDB) SelectPointValue(msg *types.ScoringMessage, campaignName, bugType string) (pointValue float64)

func (*BBashDB) SelectPriorScore

func (p *BBashDB) SelectPriorScore(participantToScore *types.ParticipantStruct, msg *types.ScoringMessage) (oldPoints float64)

func (*BBashDB) UpdateBug

func (p *BBashDB) UpdateBug(bug *types.BugStruct) (rowsAffected int64, err error)

func (*BBashDB) UpdateCampaign

func (p *BBashDB) UpdateCampaign(campaign *types.CampaignStruct) (guid string, err error)

func (*BBashDB) UpdateParticipant

func (p *BBashDB) UpdateParticipant(participant *types.ParticipantStruct) (rowsAffected int64, err error)

func (*BBashDB) UpdateParticipantScore

func (p *BBashDB) UpdateParticipantScore(participant *types.ParticipantStruct, delta float64) (err error)

func (*BBashDB) UpdateParticipantTeam

func (p *BBashDB) UpdateParticipantTeam(teamName, campaignName, scpName, loginName string) (rowsAffected int64, err error)

func (*BBashDB) ValidOrganization

func (p *BBashDB) ValidOrganization(msg *types.ScoringMessage) (orgExists bool, err error)

type IBBashDB

type IBBashDB interface {
	MigrateDB(migrateSourceURL string) error

	GetSourceControlProviders() (scps []types.SourceControlProviderStruct, err error)

	InsertCampaign(campaign *types.CampaignStruct) (guid string, err error)
	UpdateCampaign(campaign *types.CampaignStruct) (guid string, err error)
	GetCampaign(campaignName string) (campaign *types.CampaignStruct, err error)
	GetCampaigns() (campaigns []types.CampaignStruct, err error)
	GetActiveCampaigns(now time.Time) (activeCampaigns []types.CampaignStruct, err error)

	InsertOrganization(organization *types.OrganizationStruct) (guid string, err error)
	GetOrganizations() (organizations []types.OrganizationStruct, err error)
	DeleteOrganization(scpName, orgName string) (rowsAffected int64, err error)
	ValidOrganization(msg *types.ScoringMessage) (orgExists bool, err error)

	SelectParticipantsToScore(msg *types.ScoringMessage, now time.Time) (participantsToScore []types.ParticipantStruct, err error)
	SelectPointValue(msg *types.ScoringMessage, campaignName, bugType string) (pointValue float64)
	IScoreDB

	InsertParticipant(participant *types.ParticipantStruct) (err error)
	SelectParticipantDetail(campaignName, scpName, loginName string) (participant *types.ParticipantStruct, err error)
	SelectParticipantsInCampaign(campaignName string) (participants []types.ParticipantStruct, err error)
	UpdateParticipant(participant *types.ParticipantStruct) (rowsAffected int64, err error)
	DeleteParticipant(campaign, scpName, loginName string) (participantId string, err error)
	UpdateParticipantTeam(teamName, campaignName, scpName, loginName string) (rowsAffected int64, err error)

	InsertTeam(team *types.TeamStruct) (err error)

	InsertBug(bug *types.BugStruct) (err error)
	UpdateBug(bug *types.BugStruct) (rowsAffected int64, err error)
	SelectBugs() (bugs []types.BugStruct, err error)
}

type IDBPoll

type IDBPoll interface {
	GetLogger() *zap.Logger
	NewPoll() types.Poll
	UpdatePoll(poll *types.Poll) (err error)
	SelectPoll(poll *types.Poll) (err error)
}

type IScoreDB

type IScoreDB interface {
	GetDb() (db *sql.DB)
	SelectPriorScore(participantToScore *types.ParticipantStruct, msg *types.ScoringMessage) (oldPoints float64)
	InsertScoringEvent(participantToScore *types.ParticipantStruct, msg *types.ScoringMessage, newPoints float64) (err error)
	UpdateParticipantScore(participant *types.ParticipantStruct, delta float64) (err error)
}

type PollStruct

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

func NewDBPoll

func NewDBPoll(db *sql.DB, logger *zap.Logger) *PollStruct

func SetupMockDBPoll

func SetupMockDBPoll(t *testing.T) (mock sqlmock.Sqlmock, mockDbPoll *PollStruct, closeDbFunc func())

SetupMockDBPoll should always be followed by a call to the closeDbFunc, like so:

mock, db, closeDbFunc := SetupMockDBPoll(t)
defer closeDbFunc()

func (*PollStruct) GetLogger

func (p *PollStruct) GetLogger() *zap.Logger

func (*PollStruct) NewPoll

func (p *PollStruct) NewPoll() types.Poll

func (*PollStruct) SelectPoll

func (p *PollStruct) SelectPoll(poll *types.Poll) (err error)

func (*PollStruct) UpdatePoll

func (p *PollStruct) UpdatePoll(poll *types.Poll) (err error)

Jump to

Keyboard shortcuts

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