From bb95f1ba97f02164edb75782ff2287eebd304c2f Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Thu, 23 Dec 2021 21:11:57 +0100 Subject: [PATCH 1/3] Some rustfmt stuff --- Cargo.toml | 2 -- Rb.yaml | 3 ++- rustfmt.toml | 3 +-- src/schema.rs | 5 +---- test.py | 4 ++-- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 70ed1df..c92476d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,6 @@ incremental = true [profile.release] lto = "fat" -incremental = true codegen-units = 1 # For releases also try to max optimizations for dependencies: @@ -59,4 +58,3 @@ codegen-units = 1 opt-level = 3 [profile.release.package."*"] opt-level = 3 - diff --git a/Rb.yaml b/Rb.yaml index 8a3f881..4bf3eac 100644 --- a/Rb.yaml +++ b/Rb.yaml @@ -1,8 +1,9 @@ default: address: "0.0.0.0" - ports: 8000 + port: 8000 debug: + port: 8001 keep_alive: 5 read_timeout: 5 write_timeout: 5 diff --git a/rustfmt.toml b/rustfmt.toml index 8e8627b..6e48dc7 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,3 +1,4 @@ +unstable_features = true binop_separator = "Front" blank_lines_lower_bound = 0 blank_lines_upper_bound = 1 @@ -49,7 +50,6 @@ reorder_imports = true reorder_modules = true report_fixme = "Always" report_todo = "Always" -required_version = "1.4.37" skip_children = false space_after_colon = true space_before_colon = false @@ -60,7 +60,6 @@ tab_spaces = 4 trailing_comma = "Vertical" trailing_semicolon = true type_punctuation_density = "Wide" -unstable_features = false use_field_init_shorthand = false use_small_heuristics = "Default" use_try_shorthand = false diff --git a/src/schema.rs b/src/schema.rs index c075395..db8b2c5 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -21,7 +21,4 @@ table! { joinable!(posts -> sections (section_id)); -allow_tables_to_appear_in_same_query!( - posts, - sections, -); +allow_tables_to_appear_in_same_query!(posts, sections,); diff --git a/test.py b/test.py index eff2639..3e1a1bb 100644 --- a/test.py +++ b/test.py @@ -12,8 +12,8 @@ data = { "shortname": "short", } -r = requests.post("http://localhost:8000/v1/sections", headers=headers, json=data) +r = requests.post("http://localhost:8000/api/v1/sections", headers=headers, json=data) print(r.content) print(r.status_code) -r = requests.get("http://localhost:8000/v1/sections?offset=0&limit=100") +r = requests.get("http://localhost:8000/api/v1/sections?offset=0&limit=100") print(r.json()) From 8284438576612366216fd9af514005129296333f Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Thu, 23 Dec 2021 23:28:26 +0100 Subject: [PATCH 2/3] Added tags table --- migrations/2021-09-13-143540_sections/down.sql | 1 + migrations/2021-09-13-143540_sections/up.sql | 9 ++++++++- src/schema.rs | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/migrations/2021-09-13-143540_sections/down.sql b/migrations/2021-09-13-143540_sections/down.sql index bd985fd..792db38 100644 --- a/migrations/2021-09-13-143540_sections/down.sql +++ b/migrations/2021-09-13-143540_sections/down.sql @@ -4,5 +4,6 @@ drop trigger update_enforce_version_titles on versions; drop function enforce_version_titles; drop table versions cascade; +drop table tags cascade; drop table posts cascade; drop table sections cascade; diff --git a/migrations/2021-09-13-143540_sections/up.sql b/migrations/2021-09-13-143540_sections/up.sql index c663de4..3334941 100644 --- a/migrations/2021-09-13-143540_sections/up.sql +++ b/migrations/2021-09-13-143540_sections/up.sql @@ -46,7 +46,14 @@ create table versions ( -- This check allows draft posts to be created without having to enter a -- publish date, but forces them to have one if they're not a draft. - CHECK (is_draft OR publish_date IS NOT NULL) + CONSTRAINT no_null_published_date CHECK (is_draft OR publish_date IS NOT NULL) +); + +create table tags ( + post_id uuid NOT NULL REFERENCES posts(id) ON DELETE CASCADE, + value varchar(64) NOT NULL, + + PRIMARY KEY (post_id, value) ); create function enforce_version_titles() returns trigger as $$ diff --git a/src/schema.rs b/src/schema.rs index 246ea3c..b032c41 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -19,6 +19,13 @@ table! { } } +table! { + tags (post_id, value) { + post_id -> Uuid, + value -> Varchar, + } +} + table! { versions (id) { id -> Uuid, @@ -31,10 +38,12 @@ table! { } joinable!(posts -> sections (section_id)); +joinable!(tags -> posts (post_id)); joinable!(versions -> posts (post_id)); allow_tables_to_appear_in_same_query!( posts, sections, + tags, versions, ); From d3ccd51170bd11a06e4722d333a14b9105ea30b6 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 24 Dec 2021 09:00:41 +0000 Subject: [PATCH 3/3] Add renovate.json --- renovate.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..7190a60 --- /dev/null +++ b/renovate.json @@ -0,0 +1,3 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json" +}