Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add min wait support to close on passing #555

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/config/.gitvote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,23 @@ profiles:
#
close_on_passing: false

# Close on passing minimum wait
# When the close on passing feature is activated, voting will conclude once
# the pass threshold is met. However, there may be instances where it is
# preferable to implement a minimum wait time, even if the vote would
# already pass. This allows participants sufficient opportunity to engage
# and reflect before the vote is automatically finalized.
#
# Units supported:
#
# - day / days
# - week / weeks 
#
# close_on_passing_min_wait: "1 week"
#
close_on_passing_min_wait: null

# Announcements
#
# GitVote can announce the results of a vote when it is closed on GitHub
Expand Down
2 changes: 2 additions & 0 deletions src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ pub(crate) struct CfgProfile {
pub periodic_status_check: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub close_on_passing: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub close_on_passing_min_wait: Option<String>,
}

impl CfgProfile {
Expand Down
6 changes: 6 additions & 0 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ impl DB for PgDB {
where closed = false
and cfg ? 'close_on_passing'
and (cfg->>'close_on_passing')::boolean = true
and
case
when cfg ? 'close_on_passing_min_wait' and string_to_interval(cfg->>'close_on_passing_min_wait') is not null then
current_timestamp > created_at + (cfg->>'close_on_passing_min_wait')::interval
else true
end
",
&[],
)
Expand Down