From bd59551bc641468985683248d055fcd35664dd66 Mon Sep 17 00:00:00 2001 From: Everett Pompeii Date: Thu, 5 Oct 2023 10:31:13 -0400 Subject: [PATCH] fixes --- Cargo.lock | 1 - scripts/smoke_test.sh | 4 +- services/api/Cargo.toml | 5 +-- services/api/src/util/typed_uuid.rs | 11 +++-- .../components/console/perf/PerfHeader.tsx | 4 +- .../components/console/perf/plot/PlotTab.tsx | 27 +++++++++++-- .../components/console/table/TablePanel.tsx | 7 ++-- .../src/components/field/kinds/Radio.tsx | 11 ++--- .../src/components/perf/PublicProjects.tsx | 11 ++--- .../src/components/site/Pagination.tsx | 40 ++++++++++--------- 10 files changed, 71 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f57ed038d..4cf039357 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -695,7 +695,6 @@ dependencies = [ "once_cell", "ordered-float", "oso", - "pretty_assertions", "rand 0.8.5", "schemars", "sentry", diff --git a/scripts/smoke_test.sh b/scripts/smoke_test.sh index 00793e634..2d60f3f4d 100755 --- a/scripts/smoke_test.sh +++ b/scripts/smoke_test.sh @@ -9,6 +9,4 @@ while ! nc -z localhost 61016; do sleep 1 done -RUST_BACKTRACE=full cargo test --features seed --test seed -- --nocapture - -source ../../scripts/mock.sh +source ../../scripts/seed.sh diff --git a/services/api/Cargo.toml b/services/api/Cargo.toml index 5a27dae12..a7500591d 100644 --- a/services/api/Cargo.toml +++ b/services/api/Cargo.toml @@ -51,16 +51,13 @@ async-compression = { version = "0.4", features = ["tokio", "gzip"] } aws-credential-types = "0.56" aws-sdk-s3 = "0.31" css-inline = "0.11" -diesel = { version = "2.1", features = ["sqlite", "chrono"] } +diesel = { version = "2.1", features = ["chrono", "sqlite"] } diesel_migrations = "2.1" hyper = "0.14" http = "0.2" mail-send = "0.4" sentry = { version = "0.31", optional = true } -[dev-dependencies] -pretty_assertions.workspace = true - [[bin]] name = "api" diff --git a/services/api/src/util/typed_uuid.rs b/services/api/src/util/typed_uuid.rs index a2d492a29..b3baaf444 100644 --- a/services/api/src/util/typed_uuid.rs +++ b/services/api/src/util/typed_uuid.rs @@ -43,15 +43,18 @@ macro_rules! typed_uuid { impl diesel::serialize::ToSql for $name where DB: diesel::backend::Backend, - str: diesel::serialize::ToSql, + for<'a> String: diesel::serialize::ToSql + + Into< + as diesel::query_builder::BindCollector<'a, DB>>::Buffer, + >, { fn to_sql<'b>( &'b self, out: &mut diesel::serialize::Output<'b, '_, DB>, ) -> diesel::serialize::Result { - // TODO it may be worth imitating this impl - // https://docs.rs/diesel/2.1.2/src/diesel/pg/types/uuid.rs.html#23 - std::str::from_utf8(self.0.as_bytes())?.to_sql(out) + // https://docs.rs/diesel/latest/diesel/serialize/trait.ToSql.html#examples + out.set_value(self.to_string()); + Ok(diesel::serialize::IsNull::No) } } diff --git a/services/console/src/components/console/perf/PerfHeader.tsx b/services/console/src/components/console/perf/PerfHeader.tsx index 029cf1d3d..aec941d8d 100644 --- a/services/console/src/components/console/perf/PerfHeader.tsx +++ b/services/console/src/components/console/perf/PerfHeader.tsx @@ -1,10 +1,10 @@ import { debounce } from "@solid-primitives/scheduled"; import { - Accessor, + type Accessor, createEffect, createMemo, createSignal, - Resource, + type Resource, Show, } from "solid-js"; import type { diff --git a/services/console/src/components/console/perf/plot/PlotTab.tsx b/services/console/src/components/console/perf/plot/PlotTab.tsx index c1957b762..5e13b9de6 100644 --- a/services/console/src/components/console/perf/plot/PlotTab.tsx +++ b/services/console/src/components/console/perf/plot/PlotTab.tsx @@ -1,4 +1,4 @@ -import { For, type Accessor, Switch, Match } from "solid-js"; +import { For, type Accessor, Switch, Match, createMemo } from "solid-js"; import { PerfTab } from "../../../../config/types"; import type { JsonBenchmark, @@ -76,6 +76,25 @@ const PlotTab = (props: Props) => { } }; + const reportsLength = createMemo(() => props.reports_tab.length); + const branchesLength = createMemo(() => props.branches_tab.length); + const testbedsLength = createMemo(() => props.testbeds_tab.length); + const benchmarksLength = createMemo(() => props.benchmarks_tab.length); + const getTabLength = () => { + switch (props.tab()) { + case PerfTab.REPORTS: + return reportsLength; + case PerfTab.BRANCHES: + return branchesLength; + case PerfTab.TESTBEDS: + return testbedsLength; + case PerfTab.BENCHMARKS: + return benchmarksLength; + default: + return () => 0; + } + }; + const getPerPage = () => { switch (props.tab()) { case PerfTab.REPORTS: @@ -174,9 +193,9 @@ const PlotTab = (props: Props) => {

diff --git a/services/console/src/components/console/table/TablePanel.tsx b/services/console/src/components/console/table/TablePanel.tsx index b3dbf838f..1ceda1c1c 100644 --- a/services/console/src/components/console/table/TablePanel.tsx +++ b/services/console/src/components/console/table/TablePanel.tsx @@ -139,6 +139,7 @@ const TablePanel = (props: Props) => { fetcher, getData, ); + const tableDataLength = createMemo(() => tableData()?.length); createEffect(() => { const newParams: Record = {}; @@ -192,9 +193,9 @@ const TablePanel = (props: Props) => {
diff --git a/services/console/src/components/field/kinds/Radio.tsx b/services/console/src/components/field/kinds/Radio.tsx index 17a6dd137..84b0b0ec4 100644 --- a/services/console/src/components/field/kinds/Radio.tsx +++ b/services/console/src/components/field/kinds/Radio.tsx @@ -27,12 +27,12 @@ export interface RadioConfig { const Radio = (props: Props) => { const params = createMemo(() => props.params); - const per_page = 8; + const per_page = createMemo(() => 8); const [page, setPage] = createSignal(1); const fetcher = createMemo(() => { return { - url: props.config?.url(params(), per_page, page()), + url: props.config?.url(params(), per_page(), page()), token: authUser()?.token, }; }); @@ -48,6 +48,7 @@ const Radio = (props: Props) => { }); }; const [data] = createResource(fetcher, getRadio); + const dataLength = createMemo(() => data()?.length); return ( <> @@ -90,7 +91,7 @@ const Radio = (props: Props) => { )} - {data()?.length === 0 && page() !== 1 && ( + {dataLength() === 0 && page() !== 1 && ( {
diff --git a/services/console/src/components/perf/PublicProjects.tsx b/services/console/src/components/perf/PublicProjects.tsx index 42baf93d7..10ca8c5ac 100644 --- a/services/console/src/components/perf/PublicProjects.tsx +++ b/services/console/src/components/perf/PublicProjects.tsx @@ -1,5 +1,5 @@ import { - Accessor, + type Accessor, createEffect, createMemo, createResource, @@ -78,6 +78,7 @@ const PublicProjects = (props: Props) => { }); }; const [projects] = createResource(fetcher, fetchProjects); + const projectsLength = createMemo(() => projects()?.length); createEffect(() => { const newParams: Record = {}; @@ -118,7 +119,7 @@ const PublicProjects = (props: Props) => { )} - {projects()?.length === 0 && page() !== 1 && ( + {projectsLength() === 0 && page() !== 1 && (
@@ -129,9 +130,9 @@ const PublicProjects = (props: Props) => { diff --git a/services/console/src/components/site/Pagination.tsx b/services/console/src/components/site/Pagination.tsx index 439f8193d..b140a8c9e 100644 --- a/services/console/src/components/site/Pagination.tsx +++ b/services/console/src/components/site/Pagination.tsx @@ -1,3 +1,5 @@ +import type { Accessor } from "solid-js"; + export enum PaginationSize { SMALL = "is-small", REGULAR = "", @@ -7,9 +9,9 @@ export enum PaginationSize { const Pagination = (props: { size: PaginationSize; - data_len: undefined | number; - per_page: number; - page: number; + data_len: Accessor; + per_page: Accessor; + page: Accessor; handlePage: (page: number) => void; }) => { return ( @@ -21,16 +23,16 @@ const Pagination = (props: {
    - {props.page > 2 && ( + {props.page() > 2 && (
  • )} - {props.page > 3 && ( + {props.page() > 3 && (
  • )} - {props.page > 1 && ( + {props.page() > 1 && (
  • )}
  • - {props.data_len === props.per_page && ( + {props.data_len() === props.per_page() && (
  • )} @@ -90,10 +92,10 @@ const Pagination = (props: {