Skip to content

Commit

Permalink
update search logic (#892)
Browse files Browse the repository at this point in the history
* update search logic

* update image object

* yarn

* yarn

* Move selector out of computeSearchMatchDb

* eric's changes :)

* yarning

* yarning

* white space :(

---------

Co-authored-by: Josh Raker <[email protected]>
  • Loading branch information
michaelwang13 and joshraker authored Aug 2, 2024
1 parent b099a63 commit 164e955
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/deploy/database-images/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export const deserializeDeployDatabaseImage = (

export const hasDeployDatabaseImage = (a: DeployDatabaseImage) => a.id !== "";
export const selectDatabaseImageById = schema.databaseImages.selectById;
export const selectDatabaseImages = schema.databaseImages.selectTable;
export const findDatabaseImageById = schema.databaseImages.findById;
export const selectDatabaseImagesAsList = createSelector(
schema.databaseImages.selectTableAsList,
(imgs) =>
Expand Down
1 change: 1 addition & 0 deletions src/deploy/database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export interface DeployDatabaseRow extends DeployDatabase {
cost: number;
diskSize: number;
containerSize: number;
imageDesc: string;
}

export const hasDeployDatabase = (a: DeployDatabase) => a.id !== "";
Expand Down
12 changes: 11 additions & 1 deletion src/deploy/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import {
type DeployDatabaseRow,
selectDatabasesByOrgAsList,
} from "../database";
import {
findDatabaseImageById,
selectDatabaseImages,
} from "../database-images";
import { findDiskById, selectDisks } from "../disk";
import {
findEnvById,
Expand Down Expand Up @@ -471,6 +475,7 @@ const computeSearchMatchDb = (
const handle = db.handle.toLocaleLowerCase();
const envHandle = db.envHandle.toLocaleLowerCase();
const dbType = db.type.toLocaleLowerCase();
const dbImage = db.imageDesc.toLocaleLowerCase();

let lastOpUser = "";
let lastOpType = "";
Expand All @@ -487,10 +492,12 @@ const computeSearchMatchDb = (
const opMatch = lastOpType !== "" && lastOpType.includes(search);
const opStatusMatch = lastOpStatus !== "" && lastOpStatus.includes(search);
const dbTypeMatch = dbType.includes(search);
const imgDescMatch = dbImage.includes(search);
const idMatch = search === db.id;

return (
handleMatch ||
imgDescMatch ||
dbTypeMatch ||
envMatch ||
opMatch ||
Expand Down Expand Up @@ -560,7 +567,8 @@ export const selectDatabasesForTable = createSelector(
selectOperationsAsList,
selectDisks,
selectServices,
(dbs, envs, ops, disks, services) =>
selectDatabaseImages,
(dbs, envs, ops, disks, services, images) =>
dbs
.map((dbb): DeployDatabaseRow => {
const env = findEnvById(envs, { id: dbb.environmentId });
Expand All @@ -581,8 +589,10 @@ export const selectDatabasesForTable = createSelector(
disk.size,
);
const metrics = calcMetrics([service]);
const img = findDatabaseImageById(images, { id: dbb.databaseImageId });
return {
...dbb,
imageDesc: img.description,
envHandle: env.handle,
lastOperation,
diskSize: disk.size,
Expand Down

0 comments on commit 164e955

Please sign in to comment.