Compare commits
3
Commits
main
...
ffe293d955
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffe293d955
|
||
|
|
c88c8fe74b
|
||
|
|
5b292a021c
|
Generated
+2
-2
@@ -2981,8 +2981,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "simodels"
|
||||
version = "0.11.3"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/simodels.git?tag=v0.11.3-main-fe9d101bd0-111#fe9d101bd019f91fe8c99c29721ccb0e6e90c92c"
|
||||
version = "0.11.4"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/simodels.git?tag=v0.11.4-4-2c1998242f-111#2c1998242fb6c1e79b14f34f40b33f5e9f90a35d"
|
||||
dependencies = [
|
||||
"josekit",
|
||||
"rand 0.10.2",
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ josekit = { version = "0.10.3" }
|
||||
utoipa = { version = "5.5.0", features = ["axum_extras"] }
|
||||
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
||||
simeta = { git = "ssh://git@git.kundeng.us/phoenix/simeta.git", tag = "v0.6.1-main-b690995806-680" }
|
||||
simodels = { git = "ssh://git@git.kundeng.us/phoenix/simodels.git", tag = "v0.11.3-main-fe9d101bd0-111" }
|
||||
simodels = { git = "ssh://git@git.kundeng.us/phoenix/simodels.git", tag = "v0.11.4-4-2c1998242f-111" }
|
||||
sienvy = { git = "ssh://git@git.kundeng.us/phoenix/sienvy.git", tag = "v0.8.0-main-d06c8fdf49-006" }
|
||||
labyrinth = { git = "ssh://git@git.kundeng.us/phoenix/labyrinth.git", tag = "v0.0.4" }
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ CREATE TABLE IF NOT EXISTS "song" (
|
||||
date_created timestamptz DEFAULT now(),
|
||||
filename TEXT NOT NULL,
|
||||
directory TEXT NOT NULL,
|
||||
file_type TEXT NOT NULL,
|
||||
user_id UUID NULL
|
||||
-- TODO: Add coverart id later. This will allow multiple songs to be linked to a single cover art
|
||||
);
|
||||
|
||||
+38
-1
@@ -137,6 +137,7 @@ pub mod endpoint {
|
||||
song.filename =
|
||||
simodels::song::generate_filename(simodels::types::MusicType::FlacExtension, true)
|
||||
.unwrap();
|
||||
// Will no longer be needed with s3
|
||||
song.directory = sienvy::environment::get_root_directory().value;
|
||||
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
@@ -159,8 +160,43 @@ pub mod endpoint {
|
||||
}
|
||||
}
|
||||
|
||||
song.file_key = format!("processed/song/{}", song.filename);
|
||||
let data_of_song = labyrinth::Data {
|
||||
raw_data: song.data.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
match lr.upload(&song.file_key, &data_of_song).await {
|
||||
Ok(_resp) => {
|
||||
match repo::song::insert(&pool, &song).await {
|
||||
Ok((date_created, id)) => {
|
||||
song.id = id;
|
||||
song.date_created = Some(date_created);
|
||||
response.message = String::from("Successful");
|
||||
response.data.push(song);
|
||||
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
response.message =
|
||||
format!("{:?} song {:?}", err.to_string(), song);
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
match song.save_to_filesystem() {
|
||||
Ok(_) => match repo::song::insert(&pool, &song).await {
|
||||
Ok(_) =>
|
||||
match repo::song::insert(&pool, &song).await {
|
||||
Ok((date_created, id)) => {
|
||||
song.id = id;
|
||||
song.date_created = Some(date_created);
|
||||
@@ -183,6 +219,7 @@ pub mod endpoint {
|
||||
)
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
|
||||
+16
-3
@@ -6,8 +6,8 @@ pub async fn insert(
|
||||
) -> Result<(time::OffsetDateTime, uuid::Uuid), sqlx::Error> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
INSERT INTO "song" (title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, filename, directory, user_id)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15) RETURNING date_created, id;
|
||||
INSERT INTO "song" (title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, filename, directory, file_key, user_id)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) RETURNING date_created, id;
|
||||
"#
|
||||
)
|
||||
.bind(&song.title)
|
||||
@@ -24,6 +24,7 @@ pub async fn insert(
|
||||
.bind(&song.audio_type)
|
||||
.bind(&song.filename)
|
||||
.bind(&song.directory)
|
||||
.bind(&song.file_key)
|
||||
.bind(song.user_id)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
@@ -133,6 +134,10 @@ pub async fn get_song(
|
||||
.try_get("directory")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
file_key: row
|
||||
.try_get("file_key")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
date_created: Some(date_created_time),
|
||||
user_id: row
|
||||
.try_get("user_id")
|
||||
@@ -228,6 +233,10 @@ pub async fn get_all_songs(pool: &sqlx::PgPool) -> Result<Vec<simodels::song::So
|
||||
.try_get("directory")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
file_key: row
|
||||
.try_get("file_key")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
date_created: Some(date_created_time),
|
||||
user_id: row
|
||||
.try_get("user_id")
|
||||
@@ -254,7 +263,7 @@ pub async fn delete_song(
|
||||
r#"
|
||||
DELETE FROM "song"
|
||||
WHERE id = $1
|
||||
RETURNING id, title, artist, album, album_artist, genre, year, disc, track, track_count, disc_count, duration, audio_type, date_created, filename, directory, user_id
|
||||
RETURNING id, title, artist, album, album_artist, genre, year, disc, track, track_count, disc_count, duration, audio_type, date_created, filename, directory, file_key, user_id
|
||||
"#,
|
||||
)
|
||||
.bind(id)
|
||||
@@ -332,6 +341,10 @@ pub async fn delete_song(
|
||||
.try_get("directory")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
file_key: row
|
||||
.try_get("file_key")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
date_created: Some(date_created_time),
|
||||
user_id: row
|
||||
.try_get("user_id")
|
||||
|
||||
@@ -61,6 +61,7 @@ CREATE TABLE IF NOT EXISTS "song" (
|
||||
date_created timestamptz DEFAULT now(),
|
||||
filename TEXT NOT NULL,
|
||||
directory TEXT NOT NULL,
|
||||
file_type TEXT NOT NULL,
|
||||
user_id UUID NULL
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user