From fc60247cca52da4cb58bc8e8028126df135ace11 Mon Sep 17 00:00:00 2001 From: Brad Harris Date: Wed, 14 Dec 2022 00:36:47 +0000 Subject: [PATCH 1/2] adding team.slug to findTeams query --- components/gitpod-db/src/typeorm/team-db-impl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/gitpod-db/src/typeorm/team-db-impl.ts b/components/gitpod-db/src/typeorm/team-db-impl.ts index e81979fe93aca2..edb25265c30dc1 100644 --- a/components/gitpod-db/src/typeorm/team-db-impl.ts +++ b/components/gitpod-db/src/typeorm/team-db-impl.ts @@ -52,7 +52,7 @@ export class TeamDBImpl implements TeamDB { const teamRepo = await this.getTeamRepo(); const queryBuilder = teamRepo .createQueryBuilder("team") - .where("team.name LIKE :searchTerm", { searchTerm: `%${searchTerm}%` }) + .where("team.name LIKE :searchTerm OR team.slug LIKE :searchTerm", { searchTerm: `%${searchTerm}%` }) .skip(offset) .take(limit) .orderBy(orderBy, orderDir); From 8ae44cfc17bdab0480cbbdb7a7ed0e6de6035558 Mon Sep 17 00:00:00 2001 From: Brad Harris Date: Wed, 14 Dec 2022 00:55:25 +0000 Subject: [PATCH 2/2] adding test for findTeams by slug --- components/gitpod-db/src/team-db.spec.db.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/gitpod-db/src/team-db.spec.db.ts b/components/gitpod-db/src/team-db.spec.db.ts index 5a5af331dd1a0f..a5cd421a87f63c 100644 --- a/components/gitpod-db/src/team-db.spec.db.ts +++ b/components/gitpod-db/src/team-db.spec.db.ts @@ -151,6 +151,17 @@ class TeamDBSpec { const result = await this.db.findTeams(0, 10, "creationTime", "DESC", searchTerm); expect(result.rows.length).to.eq(1); } + + @test(timeout(10000)) + public async findTeamsBySlug() { + const user = await this.userDb.newUser(); + await this.db.createTeam(user.id, "First Team"); + await this.db.createTeam(user.id, "Second Team"); + + const searchTerm = "first-team"; + const result = await this.db.findTeams(0, 10, "creationTime", "DESC", searchTerm); + expect(result.rows.length).to.eq(1); + } } module.exports = new TeamDBSpec();