Skip to content

Commit 577c3d5

Browse files
authored
Add min wait support to close on passing (#555)
Signed-off-by: Daniel Castaño Sánchez <[email protected]>
1 parent 3543eec commit 577c3d5

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

docs/config/.gitvote.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,23 @@ profiles:
136136
#
137137
close_on_passing: false
138138

139+
# Close on passing minimum wait
140+
# 
141+
# When the close on passing feature is activated, voting will conclude once
142+
# the pass threshold is met. However, there may be instances where it is
143+
# preferable to implement a minimum wait time, even if the vote would
144+
# already pass. This allows participants sufficient opportunity to engage
145+
# and reflect before the vote is automatically finalized.
146+
#
147+
# Units supported:
148+
#
149+
# - day / days
150+
# - week / weeks 
151+
#
152+
# close_on_passing_min_wait: "1 week"
153+
#
154+
close_on_passing_min_wait: null
155+
139156
# Announcements
140157
#
141158
# GitVote can announce the results of a vote when it is closed on GitHub

src/cfg.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ pub(crate) struct CfgProfile {
8484
pub periodic_status_check: Option<String>,
8585
#[serde(skip_serializing_if = "Option::is_none")]
8686
pub close_on_passing: Option<bool>,
87+
#[serde(skip_serializing_if = "Option::is_none")]
88+
pub close_on_passing_min_wait: Option<String>,
8789
}
8890

8991
impl CfgProfile {

src/db.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ impl DB for PgDB {
190190
where closed = false
191191
and cfg ? 'close_on_passing'
192192
and (cfg->>'close_on_passing')::boolean = true
193+
and
194+
case
195+
when cfg ? 'close_on_passing_min_wait' and string_to_interval(cfg->>'close_on_passing_min_wait') is not null then
196+
current_timestamp > created_at + (cfg->>'close_on_passing_min_wait')::interval
197+
else true
198+
end
193199
",
194200
&[],
195201
)

0 commit comments

Comments
 (0)