Compare commits

..

10 Commits

Author SHA1 Message Date
dependabot[bot]
ae74dc94bb Bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-21 00:06:11 +00:00
7d99897b0e Use ON CONFLICT upsert for genres
Some checks failed
Build docker image / Build-Docker-Image (push) Has been cancelled
rust-clippy analyze / Run rust-clippy analyzing (push) Has been cancelled
Replace the previous IF EXISTS/UPDATE/INSERT logic in the update_genre
PL/pgSQL function with a single INSERT ... ON CONFLICT DO UPDATE to
perform an atomic upsert and avoid races. Reformat the client.execute
call for readability.
2025-10-25 21:37:52 +02:00
35dc3cbf6f Remove DROP FUNCTION IF EXISTS from Genre update 2025-10-25 21:33:29 +02:00
4625adb6a4 Update .gitignore and drop update_genre first 2025-10-25 21:01:11 +02:00
65e23787f1 Add update_genre function to upsert genres
Replace previous function that managed book_genres. New SQL function
upserts the genres table by source and remote_id, updating code,
description and meta or inserting a new row. Removed book lookup and
book_genres insertion.
2025-10-25 20:49:36 +02:00
e1af1c2623 Simplify error mapping in download_file
Some checks failed
Build docker image / Build-Docker-Image (push) Has been cancelled
rust-clippy analyze / Run rust-clippy analyzing (push) Has been cancelled
2025-10-14 18:06:56 +02:00
788a6d232e Merge pull request #38 from flibusta-apps/dependabot/github_actions/github/codeql-action-4
Bump github/codeql-action from 3 to 4
2025-10-14 18:05:47 +02:00
c8fa902da9 Merge pull request #37 from flibusta-apps/dependabot/cargo/ammonia-4.1.2
Bump ammonia from 4.1.1 to 4.1.2
2025-10-14 18:05:17 +02:00
dependabot[bot]
d2ba22541c Bump github/codeql-action from 3 to 4
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3 to 4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-08 00:06:02 +00:00
dependabot[bot]
9df3aaed03 Bump ammonia from 4.1.1 to 4.1.2
Bumps [ammonia](https://github.com/rust-ammonia/ammonia) from 4.1.1 to 4.1.2.
- [Release notes](https://github.com/rust-ammonia/ammonia/releases)
- [Changelog](https://github.com/rust-ammonia/ammonia/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-ammonia/ammonia/compare/v4.1.1...v4.1.2)

---
updated-dependencies:
- dependency-name: ammonia
  dependency-version: 4.1.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-22 15:50:03 +00:00
7 changed files with 28 additions and 29 deletions

View File

@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v5 uses: actions/checkout@v6
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3

View File

@@ -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 actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v5 uses: actions/checkout@v6
- name: Install Rust toolchain - name: Install Rust toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1 uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1
@@ -49,7 +49,7 @@ jobs:
continue-on-error: true continue-on-error: true
- name: Upload analysis results to GitHub - name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3 uses: github/codeql-action/upload-sarif@v4
with: with:
sarif_file: rust-clippy-results.sarif sarif_file: rust-clippy-results.sarif
wait-for-processing: true wait-for-processing: true

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
/target /target
.vscode /.vscode
/bruno

4
Cargo.lock generated
View File

@@ -180,9 +180,9 @@ dependencies = [
[[package]] [[package]]
name = "ammonia" name = "ammonia"
version = "4.1.1" version = "4.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6b346764dd0814805de8abf899fe03065bcee69bb1a4771c785817e39f3978f" checksum = "17e913097e1a2124b46746c980134e8c954bc17a6a59bb3fde96f088d126dde6"
dependencies = [ dependencies = [
"cssparser", "cssparser",
"html5ever", "html5ever",

View File

@@ -35,7 +35,7 @@ serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140" serde_json = "1.0.140"
tokio-cron-scheduler = "0.14.0" tokio-cron-scheduler = "0.14.0"
axum = "0.8.1" axum = "0.8.1"
ammonia = "4.0.0" ammonia = "4.1.2"
maplit = "1.0.2" maplit = "1.0.2"
tracing = "0.1.41" tracing = "0.1.41"

View File

@@ -828,28 +828,26 @@ impl FromVecExpression<Genre> for Genre {
#[async_trait] #[async_trait]
impl Update for Genre { impl Update for Genre {
async fn before_update(client: &Client) -> Result<(), Box<tokio_postgres::Error>> { 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 $$ CREATE OR REPLACE FUNCTION update_genre(
DECLARE source_ smallint, remote_id_ int, code_ varchar, description_ varchar, meta_ varchar
book_id integer := -1; ) RETURNS void AS $$
genre_id integer := -1;
BEGIN BEGIN
SELECT id INTO book_id FROM books WHERE source = source_ AND remote_id = book_; INSERT INTO genres (source, remote_id, code, description, meta)
VALUES (source_, remote_id_, code_, description_, meta_)
IF book_id IS NULL THEN ON CONFLICT (source, remote_id) DO UPDATE SET
RETURN; code = EXCLUDED.code,
END IF; description = EXCLUDED.description,
meta = EXCLUDED.meta;
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);
END; END;
$$ LANGUAGE plpgsql; $$ LANGUAGE plpgsql;
" ",
, &[]).await { &[],
)
.await
{
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(err) => Err(Box::new(err)), Err(err) => Err(Box::new(err)),
} }

View File

@@ -55,7 +55,7 @@ async fn download_file(filename_str: &str) -> Result<(), Box<dyn std::error::Err
let data = response let data = response
.bytes_stream() .bytes_stream()
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)) .map_err(std::io::Error::other)
.into_async_read(); .into_async_read();
let decoder = GzipDecoder::new(data); let decoder = GzipDecoder::new(data);