survey

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package survey contains all the interactions related to creating and running a survey, including data persistence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddResult

func AddResult(ctx context.Context, surveyID string, result Result) (string, error)

AddResult will add a result set to an existing survey, returning the ID of the new result record. The timestamp of it being added is stored into the record.

func GetRagResult

func GetRagResult(score float64, amberFloor float64, greenFloor float64) string

GetRagResult returns a RAG status based on input

func GetWestrumResult

func GetWestrumResult(score int, amberFloor int, greenFloor int) string

GetWestrumResult returns a Westrum status based on input

Types

type CalculatedResult

type CalculatedResult struct {
	Team                        string  `json:"team"`
	LeadTime                    string  `json:"lead_time"`
	DeploymentFrequency         string  `json:"deployment_frequency"`
	Mttr                        string  `json:"mttr"`
	ChangeFailure               string  `json:"change_failure"`
	Westrum                     string  `json:"westrum_result"`
	WestrumScore                int     `json:"westrum_score"`
	LencioniTrust               string  `json:"lencioni_trust"`
	LencioniTrustScore          float64 `json:"lencioni_trust_score"`
	LencioniConflict            string  `json:"lencioni_conflict"`
	LencioniConflictScore       float64 `json:"lencioni_conflict_score"`
	LencioniCommitment          string  `json:"lencioni_commitment"`
	LencioniCommitmentScore     float64 `json:"lencioni_commitment_score"`
	LencioniAccountability      string  `json:"lencioni_accountability"`
	LencioniAccountabilityScore float64 `json:"lencioni_accountability_score"`
	LencioniResults             string  `json:"lencioni_results"`
	LencioniResultsScore        float64 `json:"lencioni_results_score"`
	ResponseTotal               int     `json:"total_responses"`
	DateStart                   string  `json:"date_start"`
	DateEnd                     string  `json:"date_end"`
	ShareCode                   string  `json:"share_code"`
}

CalculatedResult is the representation of Westrum/Lencioni etc.

func Calculate

func Calculate(s *Survey) (CalculatedResult, error)

Calculate will convert a survey into westrum/lencioni etc.

func CalculateResultFromGroupTotalStats

func CalculateResultFromGroupTotalStats(s GroupTotalStats) CalculatedResult

CalculateResultFromGroupTotalStats will calculate the resuls from GroupTotalStats

type GroupTotalStats

type GroupTotalStats struct {
	LeadTime        []StringTotal
	Mttr            []StringTotal
	DeployFrequency []StringTotal
	ChangeFailure   []StringTotal
	Lencioni        struct {
		Trust          int
		Conflict       int
		Commitment     int
		Accountability int
		Results        int
	}
	Westrum   int
	Responses int
}

GroupTotalStats holds the raw totals split into groups

func SplitSurveyIntoQuestionGroups

func SplitSurveyIntoQuestionGroups(s *Survey) GroupTotalStats

SplitSurveyIntoQuestionGroups will take questions and split them out into the question group

type Result

type Result struct {
	ResultID string    `json:"resultId"`
	Time     time.Time `json:"timestamp"`

	// ONS About
	CurrentRole               string `json:"current_role"`
	CurrentRoleOther          string `json:"current_role_other"`
	EmploymentStatus          string `json:"employment_status"`
	ProgrammingLanguages0     string `json:"programming_languages.0"`
	ProgrammingLanguages1     string `json:"programming_languages.1"`
	ProgrammingLanguages2     string `json:"programming_languages.2"`
	ProgrammingLanguages3     string `json:"programming_languages.3"`
	ProgrammingLanguages4     string `json:"programming_languages.4"`
	ProgrammingLanguages5     string `json:"programming_languages.5"`
	ProgrammingLanguages6     string `json:"programming_languages.6"`
	ProgrammingLanguages7     string `json:"programming_languages.7"`
	ProgrammingLanguages8     string `json:"programming_languages.8"`
	ProgrammingLanguages9     string `json:"programming_languages.9"`
	ProgrammingLanguages10    string `json:"programming_languages.10"`
	ProgrammingLanguagesOther string `json:"programming_languages_other"`

	// Culture Westrum
	AboutTheTeamInformationActivelySought   int `json:"about_the_team.information_actively_sought,string"`
	AboutTheTeamMessengersNotPunished       int `json:"about_the_team.messengers_not_punished,string"`
	AboutTheTeamResponsibilitiesShared      int `json:"about_the_team.responsibilities_shared,string"`
	AboutTheTeamCollaborationEncouraged     int `json:"about_the_team.collaboration_encouraged,string"`
	AboutTheTeamFailureCausesEnquiry        int `json:"about_the_team.failure_causes_enquiry,string"`
	AboutTheTeamNewIdeasWelcomed            int `json:"about_the_team.new_ideas_welcomed,string"`
	AboutTheTeamFailureTreatedAsOpportunity int `json:"about_the_team.failure_treated_as_opportunity,string"`

	// Cohesion Lencioni
	AboutTheTeamExtendedUnguardedDiscussion                int `json:"about_the_team_extended.unguarded_discussion,string"`
	AboutTheTeamExtendedCallOutUnproductiveBehaviour       int `json:"about_the_team_extended.call_out_unproductive_behaviour,string"`
	AboutTheTeamExtendedContributeToCollectiveGood         int `json:"about_the_team_extended.contribute_to_collective_good,string"`
	AboutTheTeamExtendedApologise                          int `json:"about_the_team_extended.apologise,string"`
	AboutTheTeamExtendedWillinglyMakeSacrifices            int `json:"about_the_team_extended.willingly_make_sacrifices,string"`
	AboutTheTeamExtendedAdmitMistakes                      int `json:"about_the_team_extended.admit_mistakes,string"`
	AboutTheTeamExtendedCompellingMeetings                 int `json:"about_the_team_extended.compelling_meetings,string"`
	AboutTheTeamExtendedLeaveMeetingsCommitted             int `json:"about_the_team_extended.leave_meetings_committed,string"`
	AboutTheTeamExtendedMoraleAffectedByFailure            int `json:"about_the_team_extended.morale_affected_by_failure,string"`
	AboutTheTeamExtendedDifficultIssuesRaised              int `json:"about_the_team_extended.difficult_issues_raised,string"`
	AboutTheTeamExtendedConcernedAboutLettingDownPeers     int `json:"about_the_team_extended.concerned_about_letting_down_peers,string"`
	AboutTheTeamExtendedComfortableDiscussingPersonalLives int `json:"about_the_team_extended.comfortable_discussing_personal_lives,string"`
	AboutTheTeamExtendedClearResolutionDiscussions         int `json:"about_the_team_extended.clear_resolution_discussions,string"`
	AboutTheTeamExtendedChallengeOneAnother                int `json:"about_the_team_extended.challenge_one_another,string"`
	AboutTheTeamExtendedSlowToSeekCredit                   int `json:"about_the_team_extended.slow_to_seek_credit,string"`

	// Metrics Accelerate
	LeadTime            string `json:"lead_time"`
	DeploymentFrequency string `json:"deployment_frequency"`
	Mttr                string `json:"mttr"`
	ChangeFailure       string `json:"change_failure"`
}

Result is a single respondent's result set for a survey. The fields mapped in the `json` marshaling MUST match the fields defined in the survey yaml configurations. Pay attention to indexes (such as Programming Languages starts at zero!).

type StringTotal

type StringTotal struct {
	Text  string
	Count int
}

StringTotal is a struct for holding counts of a string value

func CalculateKeyMetrics

func CalculateKeyMetrics(m []StringTotal) StringTotal

CalculateKeyMetrics gives a StringTotal of the most voted result

func CountStringInstance

func CountStringInstance(text string, store []StringTotal) []StringTotal

CountStringInstance counts the instances of a string and updates the map

type Survey

type Survey struct {
	SurveyID  string    `json:"surveyId"`
	Name      string    `json:"name"`
	Team      string    `json:"team"`
	Results   []Result  `json:"results"`
	CreatedAt time.Time `json:"created_at"`
	Open      bool      `json:"open"`
}

Survey is a top level representation of a survey

func Create

func Create(ctx context.Context, team string) (*Survey, error)

Create stores a new survey record for the given team. The returned `Survey` contains the

func Get

func Get(ctx context.Context, id string) (*Survey, error)

Get fetches the info and results for a survey by ID

func List

func List(ctx context.Context, closed bool) ([]*Survey, error)

List returns all the surveys currently in the data store and "open". Optionally set `closed` to `true` to include all surveys.

func (*Survey) Exists

func (s *Survey) Exists() bool

Exists returns whether the given survey exists and is validly open

Jump to

Keyboard shortcuts

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