Documentation
¶
Index ¶
- func ComparePasswords(hashedPwd string, plainPwd []byte) bool
- func GetBoolEnv(key string, fallback bool) bool
- func GetEnv(key string, fallback string) string
- func GetIntEnv(key string, fallback int) int
- func HashAndSalt(pwd []byte) (string, error)
- type ApplicationStats
- type Battle
- type BattleWarrior
- type Config
- type Database
- func (d *Database) AbandonBattle(BattleID string, WarriorID string) ([]*BattleWarrior, error)
- func (d *Database) ActivatePlanVoting(BattleID string, warriorID string, PlanID string) ([]*Plan, error)
- func (d *Database) AddWarriorToBattle(BattleID string, WarriorID string) ([]*BattleWarrior, error)
- func (d *Database) AuthWarrior(WarriorEmail string, WarriorPassword string) (*Warrior, error)
- func (d *Database) BurnPlan(BattleID string, warriorID string, PlanID string) ([]*Plan, error)
- func (d *Database) ConfirmAdmin(AdminID string) error
- func (d *Database) ConfirmLeader(BattleID string, warriorID string) error
- func (d *Database) CreateBattle(LeaderID string, BattleName string, PointValuesAllowed []string, Plans []*Plan, ...) (*Battle, error)
- func (d *Database) CreatePlan(BattleID string, warriorID string, PlanName string, PlanType string, ...) ([]*Plan, error)
- func (d *Database) CreateWarriorCorporal(WarriorName string, WarriorEmail string, WarriorPassword string, ...) (NewWarrior *Warrior, VerifyID string, RegisterErr error)
- func (d *Database) CreateWarriorPrivate(WarriorName string) (*Warrior, error)
- func (d *Database) DeleteBattle(BattleID string, warriorID string) error
- func (d *Database) EndPlanVoting(BattleID string, warriorID string, PlanID string, AutoFinishVoting bool) ([]*Plan, error)
- func (d *Database) FinalizePlan(BattleID string, warriorID string, PlanID string, PlanPoints string) ([]*Plan, error)
- func (d *Database) GetAppStats() (*ApplicationStats, error)
- func (d *Database) GetBattle(BattleID string, WarriorID string) (*Battle, error)
- func (d *Database) GetBattleActiveWarriors(BattleID string) []*BattleWarrior
- func (d *Database) GetBattleWarrior(BattleID string, WarriorID string) (*BattleWarrior, error)
- func (d *Database) GetBattleWarriors(BattleID string) []*BattleWarrior
- func (d *Database) GetBattlesByWarrior(WarriorID string) ([]*Battle, error)
- func (d *Database) GetPlans(BattleID string, WarriorID string) []*Plan
- func (d *Database) GetRegisteredWarriors() []*Warrior
- func (d *Database) GetWarrior(WarriorID string) (*Warrior, error)
- func (d *Database) GetWarriorByEmail(WarriorEmail string) (*Warrior, error)
- func (d *Database) PromoteWarrior(WarriorID string) error
- func (d *Database) RetractVote(BattleID string, WarriorID string, PlanID string) []*Plan
- func (d *Database) RetreatWarrior(BattleID string, WarriorID string) []*BattleWarrior
- func (d *Database) ReviseBattle(BattleID string, warriorID string, BattleName string, ...) error
- func (d *Database) RevisePlan(BattleID string, warriorID string, PlanID string, PlanName string, ...) ([]*Plan, error)
- func (d *Database) SetBattleLeader(BattleID string, warriorID string, LeaderID string) error
- func (d *Database) SetVote(BattleID string, WarriorID string, PlanID string, VoteValue string) (BattlePlans []*Plan, AllWarriorsVoted bool)
- func (d *Database) SkipPlan(BattleID string, warriorID string, PlanID string) ([]*Plan, error)
- func (d *Database) UpdateWarriorProfile(WarriorID string, WarriorName string, WarriorAvatar string, ...) error
- func (d *Database) VerifyWarriorAccount(VerifyID string) error
- func (d *Database) WarriorResetPassword(ResetID string, WarriorPassword string) (warriorName string, warriorEmail string, resetErr error)
- func (d *Database) WarriorResetRequest(WarriorEmail string) (resetID string, warriorName string, resetErr error)
- func (d *Database) WarriorUpdatePassword(WarriorID string, WarriorPassword string) (warriorName string, warriorEmail string, resetErr error)
- type Plan
- type Vote
- type Warrior
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComparePasswords ¶
ComparePasswords takes a password hash and compares it to entered password bytes returning true if matches false if not
func GetBoolEnv ¶
GetBoolEnv gets an environment variable and converts it to a bool and if it finds none uses fallback
func GetEnv ¶
GetEnv gets environment variable matching key string and if it finds none uses fallback string returning either the matching or fallback string
func GetIntEnv ¶
GetIntEnv gets an environment variable and converts it to an int and if it finds none uses fallback
func HashAndSalt ¶
HashAndSalt takes a password byte and salt + hashes it returning a hash string to store in db
Types ¶
type ApplicationStats ¶
type ApplicationStats struct { RegisteredCount int `json:"registeredWarriorCount"` UnregisteredCount int `json:"unregisteredWarriorCount"` BattleCount int `json:"battleCount"` PlanCount int `json:"planCount"` }
ApplicationStats includes warrior, battle, and plan counts
type Battle ¶
type Battle struct { BattleID string `json:"id"` LeaderID string `json:"leaderId"` BattleName string `json:"name"` Warriors []*BattleWarrior `json:"warriors"` Plans []*Plan `json:"plans"` VotingLocked bool `json:"votingLocked"` ActivePlanID string `json:"activePlanId"` PointValuesAllowed []string `json:"pointValuesAllowed"` AutoFinishVoting bool `json:"autoFinishVoting"` }
Battle aka arena
type BattleWarrior ¶
type BattleWarrior struct { WarriorID string `json:"id"` WarriorName string `json:"name"` WarriorRank string `json:"rank"` WarriorAvatar string `json:"avatar"` Active bool `json:"active"` Abandoned bool `json:"abandoned"` }
BattleWarrior aka user
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds all the configuration for the db
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database contains all the methods to interact with DB
func New ¶
New runs db migrations, sets up a db connection pool and sets previously active warriors to false during startup
func (*Database) AbandonBattle ¶
func (d *Database) AbandonBattle(BattleID string, WarriorID string) ([]*BattleWarrior, error)
AbandonBattle removes a warrior from the current battle by ID and sets abandoned true
func (*Database) ActivatePlanVoting ¶
func (d *Database) ActivatePlanVoting(BattleID string, warriorID string, PlanID string) ([]*Plan, error)
ActivatePlanVoting sets the plan by ID to active, wipes any previous votes/points, and disables votingLock
func (*Database) AddWarriorToBattle ¶
func (d *Database) AddWarriorToBattle(BattleID string, WarriorID string) ([]*BattleWarrior, error)
AddWarriorToBattle adds a warrior by ID to the battle by ID
func (*Database) AuthWarrior ¶
AuthWarrior attempts to authenticate the warrior
func (*Database) ConfirmAdmin ¶
ConfirmAdmin confirms whether the warrior is infact a GENERAL (ADMIN)
func (*Database) ConfirmLeader ¶
ConfirmLeader confirms the warrior is infact leader of the battle
func (*Database) CreateBattle ¶
func (d *Database) CreateBattle(LeaderID string, BattleName string, PointValuesAllowed []string, Plans []*Plan, AutoFinishVoting bool) (*Battle, error)
CreateBattle adds a new battle to the db
func (*Database) CreatePlan ¶
func (d *Database) CreatePlan(BattleID string, warriorID string, PlanName string, PlanType string, ReferenceID string, Link string, Description string, AcceptanceCriteria string) ([]*Plan, error)
CreatePlan adds a new plan to a battle
func (*Database) CreateWarriorCorporal ¶
func (d *Database) CreateWarriorCorporal(WarriorName string, WarriorEmail string, WarriorPassword string, ActiveWarriorID string) (NewWarrior *Warrior, VerifyID string, RegisterErr error)
CreateWarriorCorporal adds a new warrior corporal (registered) to the db
func (*Database) CreateWarriorPrivate ¶
CreateWarriorPrivate adds a new warrior private (guest) to the db
func (*Database) DeleteBattle ¶
DeleteBattle removes all battle associations and the battle itself from DB by BattleID
func (*Database) EndPlanVoting ¶
func (d *Database) EndPlanVoting(BattleID string, warriorID string, PlanID string, AutoFinishVoting bool) ([]*Plan, error)
EndPlanVoting sets plan to active: false
func (*Database) FinalizePlan ¶
func (d *Database) FinalizePlan(BattleID string, warriorID string, PlanID string, PlanPoints string) ([]*Plan, error)
FinalizePlan sets plan to active: false
func (*Database) GetAppStats ¶
func (d *Database) GetAppStats() (*ApplicationStats, error)
GetAppStats gets counts of warriors (registered and unregistered), battles, and plans
func (*Database) GetBattleActiveWarriors ¶
func (d *Database) GetBattleActiveWarriors(BattleID string) []*BattleWarrior
GetBattleActiveWarriors retrieves the active warriors for a given battle from db
func (*Database) GetBattleWarrior ¶
func (d *Database) GetBattleWarrior(BattleID string, WarriorID string) (*BattleWarrior, error)
GetBattleWarrior gets a warrior from db by ID and checks battle active status
func (*Database) GetBattleWarriors ¶
func (d *Database) GetBattleWarriors(BattleID string) []*BattleWarrior
GetBattleWarriors retrieves the warriors for a given battle from db
func (*Database) GetBattlesByWarrior ¶
GetBattlesByWarrior gets a list of battles by WarriorID
func (*Database) GetRegisteredWarriors ¶
GetRegisteredWarriors retrieves the registered warriors from db
func (*Database) GetWarrior ¶
GetWarrior gets a warrior from db by ID
func (*Database) GetWarriorByEmail ¶
func (*Database) PromoteWarrior ¶
PromoteWarrior promotes a warrior to GENERAL (ADMIN) rank
func (*Database) RetractVote ¶
RetractVote removes a warriors vote for the plan
func (*Database) RetreatWarrior ¶
func (d *Database) RetreatWarrior(BattleID string, WarriorID string) []*BattleWarrior
RetreatWarrior removes a warrior from the current battle by ID
func (*Database) ReviseBattle ¶
func (d *Database) ReviseBattle(BattleID string, warriorID string, BattleName string, PointValuesAllowed []string, AutoFinishVoting bool) error
ReviseBattle updates the battle by ID
func (*Database) RevisePlan ¶
func (d *Database) RevisePlan(BattleID string, warriorID string, PlanID string, PlanName string, PlanType string, ReferenceID string, Link string, Description string, AcceptanceCriteria string) ([]*Plan, error)
RevisePlan updates the plan by ID
func (*Database) SetBattleLeader ¶
SetBattleLeader sets the leaderId for the battle
func (*Database) SetVote ¶
func (d *Database) SetVote(BattleID string, WarriorID string, PlanID string, VoteValue string) (BattlePlans []*Plan, AllWarriorsVoted bool)
SetVote sets a warriors vote for the plan
func (*Database) UpdateWarriorProfile ¶
func (d *Database) UpdateWarriorProfile(WarriorID string, WarriorName string, WarriorAvatar string, NotificationsEnabled bool) error
UpdateWarriorProfile attempts to update the warriors profile
func (*Database) VerifyWarriorAccount ¶
VerifyWarriorAccount attempts to verify a warriors account email
func (*Database) WarriorResetPassword ¶
func (d *Database) WarriorResetPassword(ResetID string, WarriorPassword string) (warriorName string, warriorEmail string, resetErr error)
WarriorResetPassword attempts to reset a warriors password
type Plan ¶
type Plan struct { PlanID string `json:"id"` PlanName string `json:"name"` Type string `json:"type"` ReferenceID string `json:"referenceId"` Link string `json:"link"` Description string `json:"description"` AcceptanceCriteria string `json:"acceptanceCriteria"` Votes []*Vote `json:"votes"` Points string `json:"points"` PlanActive bool `json:"active"` PlanSkipped bool `json:"skipped"` VoteStartTime time.Time `json:"voteStartTime"` VoteEndTime time.Time `json:"voteEndTime"` }
Plan aka Story structure
type Warrior ¶
type Warrior struct { WarriorID string `json:"id"` WarriorName string `json:"name"` WarriorEmail string `json:"email"` WarriorRank string `json:"rank"` WarriorAvatar string `json:"avatar"` Verified bool `json:"verified"` NotificationsEnabled bool `json:"notificationsEnabled"` }
Warrior aka user