Skip to content

Commit

Permalink
feat: simplify mod_downloads (#42)
Browse files Browse the repository at this point in the history
* feat: temp snapshot commit

* feat: temp commit

* feat(downloads): simplify everything

* chore: sqlx prepare

* fix: remove unused imports
  • Loading branch information
Fleeym authored Jan 18, 2025
1 parent 13b9823 commit d958293
Show file tree
Hide file tree
Showing 29 changed files with 226 additions and 497 deletions.

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

This file was deleted.

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

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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

21 changes: 7 additions & 14 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::{jobs, AppData};
use anyhow::anyhow;
use clap::{Parser, Subcommand};
use sqlx::Acquire;

#[derive(Debug, Parser)]
#[command(version, about, long_about = None)]
Expand All @@ -19,8 +17,8 @@ pub enum Commands {

#[derive(Debug, Subcommand)]
pub enum JobCommand {
/// Caches download counts for all mods currently stored
CacheDownloads,
/// Cleans up mod_downloads from more than 30 days ago
CleanupDownloads,
/// Runs migrations
Migrate,
}
Expand All @@ -31,20 +29,15 @@ pub async fn maybe_cli(data: &AppData) -> anyhow::Result<bool> {
if let Some(c) = cli.command {
return match c {
Commands::Job(job) => match job {
JobCommand::CacheDownloads => {
JobCommand::Migrate => {
let mut conn = data.db.acquire().await?;
let mut transaction = conn.begin().await?;

jobs::download_cache::start(&mut transaction)
.await
.map_err(|e| anyhow!("Failed to update download cache {}", e))?;
jobs::migrate::migrate(&mut conn).await?;

transaction.commit().await?;
Ok(true)
}
JobCommand::Migrate => {
},
JobCommand::CleanupDownloads => {
let mut conn = data.db.acquire().await?;
jobs::migrate::migrate(&mut conn).await?;
jobs::cleanup_downloads::cleanup_downloads(&mut *conn).await?;

Ok(true)
}
Expand Down
4 changes: 3 additions & 1 deletion src/database/repository/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod mod_tags;
pub mod mods;
pub mod developers;
pub mod developers;
pub mod mod_downloads;
pub mod mod_versions;
Loading

0 comments on commit d958293

Please sign in to comment.