From 1991d0428999721900e760c1f0ce3b8a41dcac18 Mon Sep 17 00:00:00 2001 From: Ella S Date: Mon, 2 Feb 2026 10:00:34 -0500 Subject: [PATCH 1/8] Added logging of voting count info when poll closes --- database/poll.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/database/poll.go b/database/poll.go index 485d648..906fe6d 100644 --- a/database/poll.go +++ b/database/poll.go @@ -61,6 +61,17 @@ func (poll *Poll) Close(ctx context.Context) error { return err } + // log the number of people eligible to vote on that poll, the number of votes needed for quorum, and the number of votes cast + logging.Logger.WithFields(logrus.Fields{ + "method": "poll close", + "poll_id": poll.Id, + "short_description": poll.ShortDescription, + "allowed_voters": len(poll.AllowedUsers), + "quorum_type": poll.QuorumType, + "vote_type": poll.VoteType, + "votes_required": math.Ceil(float64(len(poll.AllowedUsers)) * poll.QuorumType), + }).Info("Poll {short_description} (with id {poll_id}) is now closed. There were {allowed_voters} eligible voters, and with a quorum of {quorum_type}, {votes_required} votes were required to reach quorum.") + return nil } From 9eb45f5d431edf3e7f800ffa2c0a2da7c3d1e4f9 Mon Sep 17 00:00:00 2001 From: Ella S Date: Mon, 2 Feb 2026 10:25:15 -0500 Subject: [PATCH 2/8] Update log message --- database/poll.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/database/poll.go b/database/poll.go index 906fe6d..d1f9526 100644 --- a/database/poll.go +++ b/database/poll.go @@ -70,7 +70,7 @@ func (poll *Poll) Close(ctx context.Context) error { "quorum_type": poll.QuorumType, "vote_type": poll.VoteType, "votes_required": math.Ceil(float64(len(poll.AllowedUsers)) * poll.QuorumType), - }).Info("Poll {short_description} (with id {poll_id}) is now closed. There were {allowed_voters} eligible voters, and with a quorum of {quorum_type}, {votes_required} votes were required to reach quorum.") + }).Info("Poll is now closed. Calculating results.") return nil } @@ -97,8 +97,21 @@ func CreatePoll(ctx context.Context, poll *Poll) (string, error) { if err != nil { return "", err } + poll_id := result.InsertedID.(primitive.ObjectID).Hex() - return result.InsertedID.(primitive.ObjectID).Hex(), nil + // Log the number of people eligible to vote on that poll, the number of votes needed for quorum, and whether gatekeep is required + logging.Logger.WithFields(logrus.Fields{ + "method": "poll create", + "poll_id": poll_id, + "short_description": poll.ShortDescription, + "allowed_voters": len(poll.AllowedUsers), + "quorum_type": poll.QuorumType, + "vote_type": poll.VoteType, + "votes_required": math.Ceil(float64(len(poll.AllowedUsers)) * poll.QuorumType), + "gatekeep": poll.Gatekeep, + }).Info("Poll created.") + + return poll_id, nil } func GetOpenPolls(ctx context.Context) ([]*Poll, error) { From 9153195cbc435b46af56925d5b8470e9fba55517 Mon Sep 17 00:00:00 2001 From: Ella S Date: Mon, 2 Feb 2026 11:22:52 -0500 Subject: [PATCH 3/8] removed log calls, will be displaying that info on results page instead --- database/poll.go | 27 +-------------------------- main.go | 4 ++-- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/database/poll.go b/database/poll.go index d1f9526..dd534d8 100644 --- a/database/poll.go +++ b/database/poll.go @@ -61,17 +61,6 @@ func (poll *Poll) Close(ctx context.Context) error { return err } - // log the number of people eligible to vote on that poll, the number of votes needed for quorum, and the number of votes cast - logging.Logger.WithFields(logrus.Fields{ - "method": "poll close", - "poll_id": poll.Id, - "short_description": poll.ShortDescription, - "allowed_voters": len(poll.AllowedUsers), - "quorum_type": poll.QuorumType, - "vote_type": poll.VoteType, - "votes_required": math.Ceil(float64(len(poll.AllowedUsers)) * poll.QuorumType), - }).Info("Poll is now closed. Calculating results.") - return nil } @@ -97,21 +86,7 @@ func CreatePoll(ctx context.Context, poll *Poll) (string, error) { if err != nil { return "", err } - poll_id := result.InsertedID.(primitive.ObjectID).Hex() - - // Log the number of people eligible to vote on that poll, the number of votes needed for quorum, and whether gatekeep is required - logging.Logger.WithFields(logrus.Fields{ - "method": "poll create", - "poll_id": poll_id, - "short_description": poll.ShortDescription, - "allowed_voters": len(poll.AllowedUsers), - "quorum_type": poll.QuorumType, - "vote_type": poll.VoteType, - "votes_required": math.Ceil(float64(len(poll.AllowedUsers)) * poll.QuorumType), - "gatekeep": poll.Gatekeep, - }).Info("Poll created.") - - return poll_id, nil + return result.InsertedID.(primitive.ObjectID).Hex(), nil } func GetOpenPolls(ctx context.Context) ([]*Poll, error) { diff --git a/main.go b/main.go index c58400e..8946e94 100644 --- a/main.go +++ b/main.go @@ -68,11 +68,11 @@ func main() { oidcClient.setupOidcClient(os.Getenv("VOTE_OIDC_ID"), os.Getenv("VOTE_OIDC_SECRET")) InitConstitution() - if (DEV_DISABLE_ACTIVE_FILTERS) { + if DEV_DISABLE_ACTIVE_FILTERS { logging.Logger.WithFields(logrus.Fields{"method": "main init"}).Warning("Dev disable active filters is set!") } - if (DEV_FORCE_IS_EVALS) { + if DEV_FORCE_IS_EVALS { logging.Logger.WithFields(logrus.Fields{"method": "main init"}).Warning("Dev force evals is set!") } From 9e473e60811ce340a27d9a5b525451e81de8a1e1 Mon Sep 17 00:00:00 2001 From: Ella S Date: Mon, 2 Feb 2026 12:11:02 -0500 Subject: [PATCH 4/8] Added quorum info to results page --- main.go | 26 +++++++++++++++----------- templates/result.tmpl | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index 8946e94..d014f80 100644 --- a/main.go +++ b/main.go @@ -408,18 +408,22 @@ func main() { canModify := containsString(claims.UserInfo.Groups, "active_rtp") || containsString(claims.UserInfo.Groups, "eboard") || poll.CreatedBy == claims.UserInfo.Username + votesNeededForQuorum := int(poll.QuorumType * float64(len(poll.AllowedUsers))) c.HTML(200, "result.tmpl", gin.H{ - "Id": poll.Id, - "ShortDescription": poll.ShortDescription, - "LongDescription": poll.LongDescription, - "VoteType": poll.VoteType, - "Results": results, - "IsOpen": poll.Open, - "IsHidden": poll.Hidden, - "CanModify": canModify, - "Username": claims.UserInfo.Username, - "FullName": claims.UserInfo.FullName, - "Gatekeep": poll.Gatekeep, + "Id": poll.Id, + "ShortDescription": poll.ShortDescription, + "LongDescription": poll.LongDescription, + "VoteType": poll.VoteType, + "Results": results, + "IsOpen": poll.Open, + "IsHidden": poll.Hidden, + "CanModify": canModify, + "Username": claims.UserInfo.Username, + "FullName": claims.UserInfo.FullName, + "Gatekeep": poll.Gatekeep, + "Quorum": poll.QuorumType, + "EligibleVoters": poll.AllowedUsers, + "VotesNeededForQuorum": votesNeededForQuorum, }) })) diff --git a/templates/result.tmpl b/templates/result.tmpl index f3542a6..2bbedb7 100644 --- a/templates/result.tmpl +++ b/templates/result.tmpl @@ -38,6 +38,21 @@

Results will be available once the poll closes

{{ else }} + {{/* Displays information about required quorum and number of voters */}} +
+

Number of Eligible Voters: {{ len .EligibleVoters }}

+
+ {{/* This works currently because quorum type can only be set if gatekeep is required */}} + {{ if not .Gatekeep }} +
No quorum required for this poll.
+ {{ else }} +
Quorum Type: {{ .Quorum }}
+
Votes Needed For Quorum: {{ .VotesNeededForQuorum }}
+ {{ end }} +
+
+
+
{{ range $i, $val := .Results }} {{ if eq $.VoteType "ranked" }} From 716530fc79b911425883d5748c56dcebe2d15d4b Mon Sep 17 00:00:00 2001 From: Ella S Date: Mon, 2 Feb 2026 20:55:21 -0500 Subject: [PATCH 5/8] Made it look nice, trying to display quorum type as percentage --- main.go | 5 +++++ templates/result.tmpl | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index d014f80..c6117a8 100644 --- a/main.go +++ b/main.go @@ -42,6 +42,10 @@ func MakeLinks(s string) template.HTML { return template.HTML(safe) } +func AsPercentage(num float64) string { + return fmt.Sprintf("%f", num*100.0) +} + var oidcClient = OIDCClient{} func main() { @@ -50,6 +54,7 @@ func main() { r.SetFuncMap(template.FuncMap{ "inc": inc, "MakeLinks": MakeLinks, + "AsPercent": AsPercentage, }) r.LoadHTMLGlob("templates/*") broker := sse.NewBroker() diff --git a/templates/result.tmpl b/templates/result.tmpl index 2bbedb7..b743909 100644 --- a/templates/result.tmpl +++ b/templates/result.tmpl @@ -46,7 +46,7 @@ {{ if not .Gatekeep }}
No quorum required for this poll.
{{ else }} -
Quorum Type: {{ .Quorum }}
+
Quorum Type: {{ .QuorumType }}
Votes Needed For Quorum: {{ .VotesNeededForQuorum }}
{{ end }}
From fd62275439636aa1edf3848ab64abae5a9bd6839 Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Tue, 3 Feb 2026 11:28:19 -0500 Subject: [PATCH 6/8] clean percentages --- main.go | 7 +------ templates/result.tmpl | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index c6117a8..d563bb2 100644 --- a/main.go +++ b/main.go @@ -42,10 +42,6 @@ func MakeLinks(s string) template.HTML { return template.HTML(safe) } -func AsPercentage(num float64) string { - return fmt.Sprintf("%f", num*100.0) -} - var oidcClient = OIDCClient{} func main() { @@ -54,7 +50,6 @@ func main() { r.SetFuncMap(template.FuncMap{ "inc": inc, "MakeLinks": MakeLinks, - "AsPercent": AsPercentage, }) r.LoadHTMLGlob("templates/*") broker := sse.NewBroker() @@ -426,7 +421,7 @@ func main() { "Username": claims.UserInfo.Username, "FullName": claims.UserInfo.FullName, "Gatekeep": poll.Gatekeep, - "Quorum": poll.QuorumType, + "Quorum": strconv.FormatFloat(poll.QuorumType*100.0, 'f', 0, 64), "EligibleVoters": poll.AllowedUsers, "VotesNeededForQuorum": votesNeededForQuorum, }) diff --git a/templates/result.tmpl b/templates/result.tmpl index b743909..32313ca 100644 --- a/templates/result.tmpl +++ b/templates/result.tmpl @@ -46,7 +46,7 @@ {{ if not .Gatekeep }}
No quorum required for this poll.
{{ else }} -
Quorum Type: {{ .QuorumType }}
+
Quorum Type: {{ .Quorum }}%
Votes Needed For Quorum: {{ .VotesNeededForQuorum }}
{{ end }}
From 28a9dc042c69c225bedc122d265bf6233ea102cf Mon Sep 17 00:00:00 2001 From: Ella S Date: Tue, 3 Feb 2026 11:32:16 -0500 Subject: [PATCH 7/8] Fixed merge conflict --- constitutional.go | 8 +++----- main.go | 14 +++++++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/constitutional.go b/constitutional.go index d9c98f6..9fec3ca 100644 --- a/constitutional.go +++ b/constitutional.go @@ -3,7 +3,6 @@ package main import ( "context" "fmt" - "math" "os" "strings" "time" @@ -99,10 +98,9 @@ func EvaluatePolls() { if poll.OpenedTime.AddDate(0, 0, 2).After(now) { continue } - //Two-Thirds Quorum - voterCount := len(poll.AllowedUsers) - //fuckass rounding - quorum := int(math.Ceil(float64(voterCount) * poll.QuorumType)) + + quorum := CalculateQuorum(*poll) + notVoted := make([]*OIDCUser, 0) votedCount := 0 // check all voters to see if they have voted diff --git a/main.go b/main.go index d563bb2..a5f1a2a 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "html/template" + "math" "net/http" "os" "slices" @@ -35,6 +36,17 @@ func inc(x int) string { return strconv.Itoa(x + 1) } +// Gets the number of people eligible to vote in a poll +func GetVoterCount(poll database.Poll) int { + return len(poll.AllowedUsers) +} + +// Calculates the number of votes required for quorum in a poll +func CalculateQuorum(poll database.Poll) int { + voterCount := GetVoterCount(poll) + return int(math.Ceil(float64(voterCount) * poll.QuorumType)) +} + func MakeLinks(s string) template.HTML { rx := xurls.Strict() s = template.HTMLEscapeString(s) @@ -169,7 +181,7 @@ func main() { VoteType: database.POLL_TYPE_SIMPLE, OpenedTime: time.Now(), Open: true, - QuorumType: quorum, + QuorumType: float64(quorum), Gatekeep: c.PostForm("gatekeep") == "true", AllowWriteIns: c.PostForm("allowWriteIn") == "true", Hidden: c.PostForm("hidden") == "true", From bd20158276cc1eed442ae961eb16148cf26e5c58 Mon Sep 17 00:00:00 2001 From: Ella S Date: Tue, 3 Feb 2026 11:36:23 -0500 Subject: [PATCH 8/8] Made text sizes of info consistent --- templates/result.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/result.tmpl b/templates/result.tmpl index 32313ca..890be5e 100644 --- a/templates/result.tmpl +++ b/templates/result.tmpl @@ -40,7 +40,7 @@ {{ else }} {{/* Displays information about required quorum and number of voters */}}
-

Number of Eligible Voters: {{ len .EligibleVoters }}

+
Number of Eligible Voters: {{ len .EligibleVoters }}
{{/* This works currently because quorum type can only be set if gatekeep is required */}} {{ if not .Gatekeep }}