Video Gifs #34
14
src/tags.rs
14
src/tags.rs
@@ -299,7 +299,7 @@ impl TagDao for SqliteTagDao {
|
|||||||
) -> anyhow::Result<Vec<(i64, Tag)>> {
|
) -> anyhow::Result<Vec<(i64, Tag)>> {
|
||||||
// select name, count(*) from tags join tagged_photo ON tags.id = tagged_photo.tag_id GROUP BY tags.name ORDER BY COUNT(*);
|
// select name, count(*) from tags join tagged_photo ON tags.id = tagged_photo.tag_id GROUP BY tags.name ORDER BY COUNT(*);
|
||||||
|
|
||||||
trace_db_call(&context, "query", "get_all_tags", |span| {
|
trace_db_call(context, "query", "get_all_tags", |span| {
|
||||||
span.set_attribute(KeyValue::new("path", path.clone().unwrap_or_default()));
|
span.set_attribute(KeyValue::new("path", path.clone().unwrap_or_default()));
|
||||||
|
|
||||||
let path = path.map(|p| p + "%").unwrap_or("%".to_string());
|
let path = path.map(|p| p + "%").unwrap_or("%".to_string());
|
||||||
@@ -334,7 +334,7 @@ impl TagDao for SqliteTagDao {
|
|||||||
context: &opentelemetry::Context,
|
context: &opentelemetry::Context,
|
||||||
path: &str,
|
path: &str,
|
||||||
) -> anyhow::Result<Vec<Tag>> {
|
) -> anyhow::Result<Vec<Tag>> {
|
||||||
trace_db_call(&context, "query", "get_tags_for_path", |span| {
|
trace_db_call(context, "query", "get_tags_for_path", |span| {
|
||||||
span.set_attribute(KeyValue::new("path", path.to_string()));
|
span.set_attribute(KeyValue::new("path", path.to_string()));
|
||||||
|
|
||||||
debug!("Getting Tags for path: {:?}", path);
|
debug!("Getting Tags for path: {:?}", path);
|
||||||
@@ -348,7 +348,7 @@ impl TagDao for SqliteTagDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_tag(&mut self, context: &opentelemetry::Context, name: &str) -> anyhow::Result<Tag> {
|
fn create_tag(&mut self, context: &opentelemetry::Context, name: &str) -> anyhow::Result<Tag> {
|
||||||
trace_db_call(&context, "insert", "create_tag", |span| {
|
trace_db_call(context, "insert", "create_tag", |span| {
|
||||||
span.set_attribute(KeyValue::new("name", name.to_string()));
|
span.set_attribute(KeyValue::new("name", name.to_string()));
|
||||||
|
|
||||||
diesel::insert_into(tags::table)
|
diesel::insert_into(tags::table)
|
||||||
@@ -386,7 +386,7 @@ impl TagDao for SqliteTagDao {
|
|||||||
tag_name: &str,
|
tag_name: &str,
|
||||||
path: &str,
|
path: &str,
|
||||||
) -> anyhow::Result<Option<()>> {
|
) -> anyhow::Result<Option<()>> {
|
||||||
trace_db_call(&context, "delete", "remove_tag", |span| {
|
trace_db_call(context, "delete", "remove_tag", |span| {
|
||||||
span.set_attributes(vec![
|
span.set_attributes(vec![
|
||||||
KeyValue::new("tag_name", tag_name.to_string()),
|
KeyValue::new("tag_name", tag_name.to_string()),
|
||||||
KeyValue::new("path", path.to_string()),
|
KeyValue::new("path", path.to_string()),
|
||||||
@@ -421,7 +421,7 @@ impl TagDao for SqliteTagDao {
|
|||||||
path: &str,
|
path: &str,
|
||||||
tag_id: i32,
|
tag_id: i32,
|
||||||
) -> anyhow::Result<TaggedPhoto> {
|
) -> anyhow::Result<TaggedPhoto> {
|
||||||
trace_db_call(&context, "insert", "tag_file", |span| {
|
trace_db_call(context, "insert", "tag_file", |span| {
|
||||||
span.set_attributes(vec![
|
span.set_attributes(vec![
|
||||||
KeyValue::new("path", path.to_string()),
|
KeyValue::new("path", path.to_string()),
|
||||||
KeyValue::new("tag_id", tag_id.to_string()),
|
KeyValue::new("tag_id", tag_id.to_string()),
|
||||||
@@ -464,7 +464,7 @@ impl TagDao for SqliteTagDao {
|
|||||||
exclude_tag_ids: Vec<i32>,
|
exclude_tag_ids: Vec<i32>,
|
||||||
context: &opentelemetry::Context,
|
context: &opentelemetry::Context,
|
||||||
) -> anyhow::Result<Vec<FileWithTagCount>> {
|
) -> anyhow::Result<Vec<FileWithTagCount>> {
|
||||||
trace_db_call(&context, "query", "get_files_with_all_tags", |_| {
|
trace_db_call(context, "query", "get_files_with_all_tags", |_| {
|
||||||
use diesel::dsl::*;
|
use diesel::dsl::*;
|
||||||
|
|
||||||
let exclude_subquery = tagged_photo::table
|
let exclude_subquery = tagged_photo::table
|
||||||
@@ -501,7 +501,7 @@ impl TagDao for SqliteTagDao {
|
|||||||
exclude_tag_ids: Vec<i32>,
|
exclude_tag_ids: Vec<i32>,
|
||||||
context: &opentelemetry::Context,
|
context: &opentelemetry::Context,
|
||||||
) -> anyhow::Result<Vec<FileWithTagCount>> {
|
) -> anyhow::Result<Vec<FileWithTagCount>> {
|
||||||
trace_db_call(&context, "query", "get_files_with_any_tags", |_| {
|
trace_db_call(context, "query", "get_files_with_any_tags", |_| {
|
||||||
use diesel::dsl::*;
|
use diesel::dsl::*;
|
||||||
// Create the placeholders for the IN clauses
|
// Create the placeholders for the IN clauses
|
||||||
let tag_placeholders = std::iter::repeat("?")
|
let tag_placeholders = std::iter::repeat("?")
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
use futures::future::{Inspect, MapOk};
|
use futures::TryFutureExt;
|
||||||
use futures::task::SpawnExt;
|
use log::{debug, error, info, warn};
|
||||||
use futures::{FutureExt, TryFutureExt};
|
use std::io::{Result};
|
||||||
use log::{debug, error, info, trace, warn};
|
|
||||||
use std::future::Future;
|
|
||||||
use std::io::{Result, Stdout};
|
|
||||||
use std::process::{Output, Stdio};
|
use std::process::{Output, Stdio};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub async fn generate_video_gifs() {
|
|||||||
|
|
||||||
let start = std::time::Instant::now();
|
let start = std::time::Instant::now();
|
||||||
let tracer = global_tracer();
|
let tracer = global_tracer();
|
||||||
let span = tracer.start("creating video gifs");
|
tracer.start("creating video gifs");
|
||||||
|
|
||||||
let gif_base_path = &dotenv::var("GIFS_DIRECTORY").unwrap_or(String::from("gifs"));
|
let gif_base_path = &dotenv::var("GIFS_DIRECTORY").unwrap_or(String::from("gifs"));
|
||||||
let gif_directory: &Path = Path::new(gif_base_path);
|
let gif_directory: &Path = Path::new(gif_base_path);
|
||||||
@@ -29,7 +29,7 @@ pub async fn generate_video_gifs() {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|entry| entry.ok())
|
.filter_map(|entry| entry.ok())
|
||||||
.filter(|entry| entry.file_type().is_file())
|
.filter(|entry| entry.file_type().is_file())
|
||||||
.filter(|entry| is_video(entry))
|
.filter(is_video)
|
||||||
.filter(|entry| {
|
.filter(|entry| {
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
let relative_path = &path.strip_prefix(&files).unwrap();
|
let relative_path = &path.strip_prefix(&files).unwrap();
|
||||||
@@ -43,10 +43,8 @@ pub async fn generate_video_gifs() {
|
|||||||
let gif_path = Path::new(gif_directory).join(relative_path);
|
let gif_path = Path::new(gif_directory).join(relative_path);
|
||||||
let gif_path = gif_path.with_extension("gif");
|
let gif_path = gif_path.with_extension("gif");
|
||||||
if let Some(parent_dir) = gif_path.parent() {
|
if let Some(parent_dir) = gif_path.parent() {
|
||||||
fs::create_dir_all(parent_dir).expect(&format!(
|
fs::create_dir_all(parent_dir).unwrap_or_else(|_| panic!("There was an issue creating gif directory {:?}",
|
||||||
"There was an issue creating gif directory {:?}",
|
gif_path));
|
||||||
gif_path
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
info!("Generating gif for {:?}", path);
|
info!("Generating gif for {:?}", path);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user