mod effort;
mod effort_db;
mod effort_git;
mod flags;
mod misc;
mod types;
#[cfg(test)]
mod tests;
pub use types::BackfillArgs;
use types::BackfillSubcommand;
use tga::core::config::Config;
use tga::core::db::Database;
fn resolve_backfill_date_range(
args: &BackfillArgs,
) -> anyhow::Result<(Option<String>, Option<String>)> {
use crate::commands::date_range::resolve_date_range;
resolve_date_range(
args.weeks,
args.since.as_deref(),
args.until.as_deref(),
None,
)
}
pub async fn run(config: Config, db: &mut Database, args: BackfillArgs) -> anyhow::Result<()> {
let (since, until) = resolve_backfill_date_range(&args)?;
let repos = args.repos.clone();
match args.subcommand {
BackfillSubcommand::AiDetection => flags::backfill_ai_detection(db, args.dry_run),
BackfillSubcommand::RevertFlags => flags::backfill_revert_flags(
db,
args.dry_run,
&repos,
since.as_deref(),
until.as_deref(),
),
BackfillSubcommand::TicketIds => {
flags::backfill_ticket_ids(db, args.dry_run, &repos, since.as_deref(), until.as_deref())
}
BackfillSubcommand::Reachability => {
misc::backfill_reachability(config, db, &repos, args.dry_run)
}
BackfillSubcommand::Effort(effort_args) => effort::backfill_effort(
config,
db,
effort_args,
&repos,
since.as_deref(),
until.as_deref(),
args.dry_run,
),
BackfillSubcommand::Complexity(complexity_args) => {
misc::backfill_complexity(config, db, complexity_args, args.dry_run).await
}
BackfillSubcommand::Ticketed => {
flags::backfill_ticketed(db, args.dry_run, &repos, since.as_deref(), until.as_deref())
}
BackfillSubcommand::AiDetectionCommits => flags::backfill_ai_detection_commits(
db,
args.dry_run,
&repos,
since.as_deref(),
until.as_deref(),
),
BackfillSubcommand::TopLevel => misc::backfill_top_level(db, args.dry_run),
BackfillSubcommand::EffortTshirt => effort::backfill_effort_tshirt(db, args.dry_run),
BackfillSubcommand::Quality => misc::backfill_quality(db, args.dry_run),
}
}