Skip to content

Commit

Permalink
fix: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TroyKomodo committed Jan 17, 2024
1 parent 5e2d7ac commit f0bb543
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions platform/api/src/igdb_cron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async fn cron<G: ApiGlobal>(global: &Arc<G>, config: &IgDbConfig) -> anyhow::Res
.publish(config.igdb_cron_subject.clone(), Bytes::new())
.await
.context("publish")?;
tracing::debug!("igdb cron");
timer.tick().await;
}
}
Expand Down Expand Up @@ -337,7 +338,7 @@ async fn refresh_igdb<G: ApiGlobal>(global: &Arc<G>, config: &IgDbConfig) -> any
failed: None,
name: format!("igdb/cover/{}.jpg", cover.image_id),
owner_id: None,
path: format!("https://images.igdb.com/igdb/image/upload/t_cover_big/{}.jpg", cover.image_id),
path: format!("https://images.igdb.com/igdb/image/upload/t_cover_big_2x/{}.jpg", cover.image_id),
status: UploadedFileStatus::Unqueued,
metadata: UploadedFileMetadata {
metadata: Some(uploaded_file_metadata::Metadata::Image(uploaded_file_metadata::Image {
Expand All @@ -355,7 +356,7 @@ async fn refresh_igdb<G: ApiGlobal>(global: &Arc<G>, config: &IgDbConfig) -> any
failed: None,
name: format!("igdb/artwork/{}.jpg", artwork.image_id),
owner_id: None,
path: format!("https://images.igdb.com/igdb/image/upload/t_1080p/{}.jpg", artwork.image_id),
path: format!("https://images.igdb.com/igdb/image/upload/t_1080p_2x/{}.jpg", artwork.image_id),
status: UploadedFileStatus::Unqueued,
metadata: UploadedFileMetadata {
metadata: Some(uploaded_file_metadata::Metadata::Image(uploaded_file_metadata::Image {
Expand Down Expand Up @@ -493,7 +494,7 @@ async fn refresh_igdb<G: ApiGlobal>(global: &Arc<G>, config: &IgDbConfig) -> any
if !unqueued.is_empty() {
let image_processor_config = global.config::<ImageUploaderConfig>();
common::database::query("INSERT INTO image_jobs (id, priority, task) ")
.push_values(unqueued, |mut sep, item| {
.push_values(&unqueued, |mut sep, item| {
sep.push_bind(item.id);
sep.push_bind(image_processor_config.igdb_image_task_priority);
sep.push_bind(common::database::Protobuf(create_task(
Expand All @@ -506,6 +507,13 @@ async fn refresh_igdb<G: ApiGlobal>(global: &Arc<G>, config: &IgDbConfig) -> any
.push("ON CONFLICT (id) DO NOTHING;")
.build()
.execute(&tx).await.context("insert image_jobs")?;

common::database::query("UPDATE uploaded_files SET status = 'queued' WHERE id = ANY($1)")
.bind(unqueued.iter().map(|x| x.id).collect::<Vec<_>>())
.build()
.execute(&tx)
.await
.context("update uploaded_files")?;
}
}

Expand Down

0 comments on commit f0bb543

Please sign in to comment.