Skip to content

Commit cd289d4

Browse files
jeanp413roboquat
authored andcommitted
[code-sync] Update /v1/collection endpoint response
Ref microsoft/vscode#168115
1 parent ab0f640 commit cd289d4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

components/gitpod-db/src/typeorm/code-sync-resource-db.spec.db.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export class CodeSyncResourceDBSpec {
177177

178178
@test()
179179
async createDeleteCollection(): Promise<void> {
180-
const currentCollections1 = await this.db.getCollections(this.userId);
180+
const currentCollections1 = (await this.db.getCollections(this.userId)).map(({ id }) => id);
181181
expect(currentCollections1).to.be.empty;
182182

183183
const collections: string[] = [];
@@ -186,20 +186,20 @@ export class CodeSyncResourceDBSpec {
186186
}
187187
expect(collections.length).to.be.equal(5);
188188

189-
const currentCollections2 = await this.db.getCollections(this.userId);
189+
const currentCollections2 = (await this.db.getCollections(this.userId)).map(({ id }) => id);
190190
expect(currentCollections2.sort()).to.deep.equal(collections.slice().sort());
191191

192192
await this.db.deleteCollection(this.userId, collections[0], async () => {});
193193
await this.db.deleteCollection(this.userId, collections[1], async () => {});
194194
collections.shift();
195195
collections.shift();
196196

197-
const currentCollections3 = await this.db.getCollections(this.userId);
197+
const currentCollections3 = (await this.db.getCollections(this.userId)).map(({ id }) => id);
198198
expect(currentCollections3.sort()).to.deep.equal(collections.slice().sort());
199199

200200
await this.db.deleteCollection(this.userId, undefined, async () => {});
201201

202-
const currentCollections4 = await this.db.getCollections(this.userId);
202+
const currentCollections4 = (await this.db.getCollections(this.userId)).map(({ id }) => id);
203203
expect(currentCollections4).to.be.empty;
204204
}
205205

components/gitpod-db/src/typeorm/code-sync-resource-db.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,13 @@ export class CodeSyncResourceDB {
271271
.getMany();
272272
}
273273

274-
async getCollections(userId: string): Promise<string[]> {
274+
async getCollections(userId: string): Promise<{ id: string }[]> {
275275
const connection = await this.typeORM.getConnection();
276276
const result = await connection.manager
277277
.createQueryBuilder(DBCodeSyncCollection, "collection")
278278
.where("collection.userId = :userId AND collection.deleted = 0", { userId })
279279
.getMany();
280-
return result.map((r) => r.collection);
280+
return result.map((r) => ({ id: r.collection }));
281281
}
282282

283283
async isCollection(userId: string, collection: string): Promise<boolean> {

0 commit comments

Comments
 (0)