Compare commits

...

5 Commits

2 changed files with 40 additions and 32 deletions

View File

@@ -112,7 +112,7 @@ services:
build: build:
dockerfile: packages/hoppscotch-backend/Dockerfile dockerfile: packages/hoppscotch-backend/Dockerfile
context: . context: .
target: dev target: prod
env_file: env_file:
- ./.env - ./.env
restart: always restart: always
@@ -122,7 +122,7 @@ services:
- PORT=3000 - PORT=3000
volumes: volumes:
# Uncomment the line below when modifying code. Only applicable when using the "dev" target. # Uncomment the line below when modifying code. Only applicable when using the "dev" target.
- ./packages/hoppscotch-backend/:/usr/src/app # - ./packages/hoppscotch-backend/:/usr/src/app
- /usr/src/app/node_modules/ - /usr/src/app/node_modules/
depends_on: depends_on:
hoppscotch-db: hoppscotch-db:

View File

@@ -1125,7 +1125,7 @@ export class TeamCollectionService {
id: searchResults[i].id, id: searchResults[i].id,
path: !fetchedParentTree path: !fetchedParentTree
? [] ? []
: ([fetchedParentTree.right] as CollectionSearchNode[]), : (fetchedParentTree.right as CollectionSearchNode[]),
}); });
} }
@@ -1151,8 +1151,8 @@ export class TeamCollectionService {
select id,title,'collection' AS type select id,title,'collection' AS type
from "TeamCollection" from "TeamCollection"
where "TeamCollection"."teamID"=${teamID} where "TeamCollection"."teamID"=${teamID}
and titlesearch @@ to_tsquery(${searchQuery}) and titlesearch @@ plainto_tsquery(${searchQuery})
order by ts_rank(titlesearch,to_tsquery(${searchQuery})) order by ts_rank(titlesearch,plainto_tsquery(${searchQuery}))
limit ${take} limit ${take}
OFFSET ${skip === 0 ? 0 : (skip - 1) * take}; OFFSET ${skip === 0 ? 0 : (skip - 1) * take};
`; `;
@@ -1183,8 +1183,8 @@ export class TeamCollectionService {
select id,title,request->>'method' as method,'request' AS type select id,title,request->>'method' as method,'request' AS type
from "TeamRequest" from "TeamRequest"
where "TeamRequest"."teamID"=${teamID} where "TeamRequest"."teamID"=${teamID}
and titlesearch @@ to_tsquery(${searchQuery}) and titlesearch @@ plainto_tsquery(${searchQuery})
order by ts_rank(titlesearch,to_tsquery(${searchQuery})) order by ts_rank(titlesearch,plainto_tsquery(${searchQuery}))
limit ${take} limit ${take}
OFFSET ${skip === 0 ? 0 : (skip - 1) * take}; OFFSET ${skip === 0 ? 0 : (skip - 1) * take};
`; `;
@@ -1250,45 +1250,53 @@ export class TeamCollectionService {
* @returns The parent tree of the parent collections * @returns The parent tree of the parent collections
*/ */
private generateParentTree(parentCollections: ParentTreeQueryReturnType[]) { private generateParentTree(parentCollections: ParentTreeQueryReturnType[]) {
function findChildren(id) { function findChildren(id: string): CollectionSearchNode[] {
const collection = parentCollections.filter((item) => item.id === id)[0]; const collection = parentCollections.filter((item) => item.id === id)[0];
if (collection.parentID == null) { if (collection.parentID == null) {
return { return <CollectionSearchNode[]>[
id: collection.id, {
title: collection.title, id: collection.id,
type: 'collection', title: collection.title,
path: [], type: 'collection' as const,
}; path: [],
},
];
} }
const res = { const res = <CollectionSearchNode[]>[
id: collection.id, {
title: collection.title, id: collection.id,
type: 'collection', title: collection.title,
path: findChildren(collection.parentID), type: 'collection' as const,
}; path: findChildren(collection.parentID),
},
];
return res; return res;
} }
if (parentCollections.length > 0) { if (parentCollections.length > 0) {
if (parentCollections[0].parentID == null) { if (parentCollections[0].parentID == null) {
return { return <CollectionSearchNode[]>[
{
id: parentCollections[0].id,
title: parentCollections[0].title,
type: 'collection',
path: [],
},
];
}
return <CollectionSearchNode[]>[
{
id: parentCollections[0].id, id: parentCollections[0].id,
title: parentCollections[0].title, title: parentCollections[0].title,
type: 'collection', type: 'collection',
path: [], path: findChildren(parentCollections[0].parentID),
}; },
} ];
return {
id: parentCollections[0].id,
title: parentCollections[0].title,
type: 'collection',
path: findChildren(parentCollections[0].parentID),
};
} }
return null; return <CollectionSearchNode[]>[];
} }
/** /**