Skip to content

Commit

Permalink
Merge branch 'master' into allow-setting-review-assignment-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
apiraino committed Sep 10, 2024
2 parents 6d01f91 + c35ff9f commit ca072b9
Show file tree
Hide file tree
Showing 15 changed files with 729 additions and 60 deletions.
127 changes: 116 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ ignore = "0.4.18"
postgres-types = { version = "0.2.4", features = ["derive"] }
cron = { version = "0.12.0" }
bytes = "1.1.0"
structopt = "0.3.26"

[dependencies.serde]
version = "1"
Expand Down
34 changes: 34 additions & 0 deletions src/bin/project_goals.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use structopt::StructOpt;
use triagebot::{github::GithubClient, handlers::project_goals};

/// A basic example
#[derive(StructOpt, Debug)]
struct Opt {
/// If specified, no messages are sent.
#[structopt(long)]
dry_run: bool,

/// Goals with an updated within this threshold will not be pinged.
days_threshold: i64,

/// A string like "on Sep-5" when the update blog post will be written.
next_meeting_date: String,
}

#[tokio::main(flavor = "current_thread")]
async fn main() -> anyhow::Result<()> {
dotenv::dotenv().ok();
tracing_subscriber::fmt::init();

let opt = Opt::from_args();
let gh = GithubClient::new_from_env();
project_goals::ping_project_goals_owners(
&gh,
opt.dry_run,
opt.days_threshold,
&opt.next_meeting_date,
)
.await?;

Ok(())
}
23 changes: 14 additions & 9 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn cert() {
make_certificates();
}

pub async fn run_migrations(client: &DbClient) -> anyhow::Result<()> {
pub async fn run_migrations(client: &mut DbClient) -> anyhow::Result<()> {
client
.execute(
"CREATE TABLE IF NOT EXISTS database_versions (
Expand Down Expand Up @@ -182,17 +182,22 @@ pub async fn run_migrations(client: &DbClient) -> anyhow::Result<()> {

for (idx, migration) in MIGRATIONS.iter().enumerate() {
if idx >= migration_idx {
client
.execute(*migration, &[])
let tx = client
.transaction()
.await
.context("Cannot create migration transactin")?;
tx.execute(*migration, &[])
.await
.with_context(|| format!("executing {}th migration", idx))?;
client
.execute(
"UPDATE database_versions SET migration_counter = $1",
&[&(idx as i32 + 1)],
)
tx.execute(
"UPDATE database_versions SET migration_counter = $1",
&[&(idx as i32 + 1)],
)
.await
.with_context(|| format!("updating migration counter to {}", idx))?;
tx.commit()
.await
.with_context(|| format!("updating migration counter to {}", idx))?;
.context("Cannot commit migration transaction")?;
}
}

Expand Down
Loading

0 comments on commit ca072b9

Please sign in to comment.