mirror of
https://github.com/flibusta-apps/library_updater.git
synced 2025-12-06 15:45:36 +01:00
Compare commits
5 Commits
e1af1c2623
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae74dc94bb | ||
| 7d99897b0e | |||
| 35dc3cbf6f | |||
| 4625adb6a4 | |||
| 65e23787f1 |
2
.github/workflows/build_docker_image.yml
vendored
2
.github/workflows/build_docker_image.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
2
.github/workflows/rust-clippy.yml
vendored
2
.github/workflows/rust-clippy.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
/target
|
||||
.vscode
|
||||
/.vscode
|
||||
/bruno
|
||||
|
||||
34
src/types.rs
34
src/types.rs
@@ -828,28 +828,26 @@ impl FromVecExpression<Genre> for Genre {
|
||||
#[async_trait]
|
||||
impl Update for Genre {
|
||||
async fn before_update(client: &Client) -> Result<(), Box<tokio_postgres::Error>> {
|
||||
match client.execute(
|
||||
match client
|
||||
.execute(
|
||||
"
|
||||
CREATE OR REPLACE FUNCTION update_book_sequence(source_ smallint, book_ integer, genre_ integer) RETURNS void AS $$
|
||||
DECLARE
|
||||
book_id integer := -1;
|
||||
genre_id integer := -1;
|
||||
CREATE OR REPLACE FUNCTION update_genre(
|
||||
source_ smallint, remote_id_ int, code_ varchar, description_ varchar, meta_ varchar
|
||||
) RETURNS void AS $$
|
||||
BEGIN
|
||||
SELECT id INTO book_id FROM books WHERE source = source_ AND remote_id = book_;
|
||||
|
||||
IF book_id IS NULL THEN
|
||||
RETURN;
|
||||
END IF;
|
||||
|
||||
SELECT id INTO genre_id FROM genres WHERE source = source_ AND remote_id = genre_;
|
||||
IF EXISTS (SELECT * FROM book_genres WHERE book = book_id AND genre = genre_id) THEN
|
||||
RETURN;
|
||||
END IF;
|
||||
INSERT INTO book_genres (book, genre) VALUES (book_id, genre_id);
|
||||
INSERT INTO genres (source, remote_id, code, description, meta)
|
||||
VALUES (source_, remote_id_, code_, description_, meta_)
|
||||
ON CONFLICT (source, remote_id) DO UPDATE SET
|
||||
code = EXCLUDED.code,
|
||||
description = EXCLUDED.description,
|
||||
meta = EXCLUDED.meta;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
"
|
||||
, &[]).await {
|
||||
",
|
||||
&[],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => Err(Box::new(err)),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user