Skip to content

Commit

Permalink
fix: show all info in the no results table
Browse files Browse the repository at this point in the history
  • Loading branch information
SaraVieira authored and skeptrunedev committed Sep 17, 2024
1 parent 72b43cc commit 17105a7
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 50 deletions.
60 changes: 29 additions & 31 deletions frontends/analytics/src/components/charts/NoResultQueries.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { AnalyticsFilter, SearchQueryEvent } from "shared/types";
import { createSignal, Show } from "solid-js";
import { FullScreenModal, SortableColumnDef, TanStackTable } from "shared/ui";
import { SearchQueryEventModal } from "../../pages/TrendExplorer";
import { Show } from "solid-js";
import { SortableColumnDef, TanStackTable } from "shared/ui";
import { useNoResultsQueries } from "../../hooks/data/useNoResultsQuery";
import { createSolidTable, getCoreRowModel } from "@tanstack/solid-table";
import { format } from "date-fns";
import { parseCustomDateString } from "../../utils/formatDate";
import { formatSearchMethod } from "../../utils/searchType";

interface NoResultQueriesProps {
params: {
Expand All @@ -12,15 +14,28 @@ interface NoResultQueriesProps {
}

const columns: SortableColumnDef<SearchQueryEvent>[] = [
{
accessorKey: "created_at",
header: "Searched At",
sortable: true,
cell(props) {
return format(
parseCustomDateString(props.getValue<string>()),

Check warning on line 23 in frontends/analytics/src/components/charts/NoResultQueries.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

frontends/analytics/src/components/charts/NoResultQueries.tsx#L23

[solid/reactivity] The reactive variable 'props.getValue' should be used within JSX, a tracked scope (like createEffect), or inside an event handler function, or else changes will be ignored.
"M/d/yy h:mm a",
);
},
},
{
accessorKey: "query",
header: "Query",
},
{
accessorKey: "search_type",
header: "Search Type",
cell(props) {
return (
<span class="block max-w-[400px] truncate">
{props.getValue<string>()}
</span>
);
return typeof props.getValue<unknown>() === "string"

Check warning on line 36 in frontends/analytics/src/components/charts/NoResultQueries.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

frontends/analytics/src/components/charts/NoResultQueries.tsx#L36

[solid/reactivity] The reactive variable 'props.getValue' should be used within JSX, a tracked scope (like createEffect), or inside an event handler function, or else changes will be ignored.
? formatSearchMethod(props.getValue<string>())

Check warning on line 37 in frontends/analytics/src/components/charts/NoResultQueries.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

frontends/analytics/src/components/charts/NoResultQueries.tsx#L37

[solid/reactivity] The reactive variable 'props.getValue' should be used within JSX, a tracked scope (like createEffect), or inside an event handler function, or else changes will be ignored.
: "All";
},
},
{
Expand All @@ -30,11 +45,13 @@ const columns: SortableColumnDef<SearchQueryEvent>[] = [
return props.getValue<number>() + "ms";

Check warning on line 45 in frontends/analytics/src/components/charts/NoResultQueries.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

frontends/analytics/src/components/charts/NoResultQueries.tsx#L45

[solid/reactivity] The reactive variable 'props.getValue' should be used within JSX, a tracked scope (like createEffect), or inside an event handler function, or else changes will be ignored.
},
},
{
accessorKey: "top_score",
header: "Top Score",
},
];

export const NoResultQueries = (props: NoResultQueriesProps) => {
const [open, setOpen] = createSignal(false);
const [current, setCurrent] = createSignal<SearchQueryEvent | null>(null);
const { notResultQuery, pages } = useNoResultsQueries({
params: props.params,

Check warning on line 56 in frontends/analytics/src/components/charts/NoResultQueries.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

frontends/analytics/src/components/charts/NoResultQueries.tsx#L56

[solid/reactivity] The reactive variable 'props.params' should be used within JSX, a tracked scope (like createEffect), or inside an event handler function, or else changes will be ignored.
});
Expand All @@ -52,6 +69,7 @@ export const NoResultQueries = (props: NoResultQueriesProps) => {
getCoreRowModel: getCoreRowModel(),
manualPagination: true,
});
console.log(notResultQuery.data);

return (
<>
Expand All @@ -63,27 +81,7 @@ export const NoResultQueries = (props: NoResultQueriesProps) => {
fallback={<div class="py-8 text-center">Loading...</div>}
when={notResultQuery.data}
>
<Show when={current()}>
{(data) => (
<FullScreenModal
title={data().query}
show={open}
setShow={setOpen}
>
<SearchQueryEventModal searchEvent={data()} />
</FullScreenModal>
)}
</Show>
<TanStackTable
table={table}
pages={pages}
perPage={10}
small
onRowClick={(row) => {
setCurrent(row);
setOpen(true);
}}
/>
<TanStackTable table={table} pages={pages} perPage={10} />
</Show>
</div>
</>
Expand Down
2 changes: 1 addition & 1 deletion frontends/analytics/src/pages/SearchAnalyticsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const SearchAnalyticsPage = () => {
class="flex flex-col justify-between px-4"
title="No Result Queries"
subtitle="Searches with no results"
width={5}
width={12}
>
<NoResultQueries params={analyticsFilters} />
</Card>
Expand Down
14 changes: 1 addition & 13 deletions frontends/analytics/src/pages/tablePages/SearchTablePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
SortingState,
} from "@tanstack/solid-table";
import { Card } from "../../components/charts/Card";
import { formatSearchMethod } from "../../utils/searchType";

const columns: SortableColumnDef<SearchQueryEvent>[] = [
{
Expand Down Expand Up @@ -127,16 +128,3 @@ export const SearchTablePage = () => {
</div>
);
};

const formatSearchMethod = (searchMethod: string) => {
switch (searchMethod) {
case "hybrid":
return "Hybrid";
case "fulltext":
return "Fulltext";
case "semantic":
return "Semantic";
default:
return "All";
}
};
14 changes: 14 additions & 0 deletions frontends/analytics/src/utils/searchType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const formatSearchMethod = (searchMethod: string) => {
switch (searchMethod) {
case "hybrid":
return "Hybrid";
case "fulltext":
return "Fulltext";
case "semantic":
return "Semantic";
case "autocomplete":
return "Autocomplete";
default:
return "All";
}
};
2 changes: 1 addition & 1 deletion frontends/shared/ui/FullscreenModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const FullScreenModal = (props: FullScreenModalProps) => {
<div class="flex items-center justify-between">
<DialogTitle
as="h3"
class="text-lg font-medium leading-6 text-neutral-900 mb-4"
class="text-lg font-medium leading-6 text-neutral-900 mb-4 max-w-[80%] text-ellipsis truncate"
>
{title()}
</DialogTitle>
Expand Down
11 changes: 7 additions & 4 deletions frontends/shared/ui/TanStackTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ export const TanStackTable = (props: TableProps) => {
"whitespace-nowrap text-sm font-medium text-neutral-900"
)}
>
{flexRender(
cell.column.columnDef.cell,
cell.getContext()
)}
<span class="max-w-[300px] truncate 2xl:max-w-full text-ellipsis block">
{" "}
{flexRender(
cell.column.columnDef.cell,
cell.getContext()
)}
</span>
</td>
)}
</For>
Expand Down

0 comments on commit 17105a7

Please sign in to comment.