Skip to content

Commit e634799

Browse files
committed
feat(patch-browser): only show patches with connections
1 parent 32fabb0 commit e634799

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/app/features/backend/DatabaseStrings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export class QueryJoins {
3636
// Patch
3737
static patch: string = 'patch:patches!patch_connections_patchid_fkey(*)';
3838

39+
// Patch Connections
40+
static patch_connections: string = 'patch_connections:patch_connections!patch_connections_patchid_fkey(*)';
41+
3942
// Author
4043
static author: string = 'author:authorid(username,id,email)';
4144

src/app/features/backend/supabase.service.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,30 +1082,28 @@ export class SupabaseService {
10821082
name?: string,
10831083
orderBy?: string,
10841084
orderDirection?: string,
1085-
columns: string = `id,name,description,${ QueryJoins.author },updated,created `) {
1086-
1087-
let queryBuilder = this.supabase.from(DbPaths.patches)
1088-
.select(columns, {count: 'exact'})
1085+
columns: string = `id,name,description,${ QueryJoins.author },updated,created`
1086+
) {
1087+
const connections = `,patch_connections!inner(patchid,a,b)`; // Ensures only patches with connections are included
10891088

1089+
let queryBuilder = this.supabase
1090+
.from(DbPaths.patches)
1091+
.select(columns + connections, {count: 'exact'})
1092+
.order(orderBy ?? 'name', {ascending: orderDirection === 'asc'});
10901093

10911094
if (columns.includes('name')) {
1092-
queryBuilder = queryBuilder
1093-
.order(orderBy ? orderBy : 'name', {ascending: orderDirection === 'asc'})
1095+
queryBuilder = queryBuilder.order(orderBy ?? 'name', {ascending: orderDirection === 'asc'});
10941096
}
10951097

10961098
if (name) {
1097-
queryBuilder = queryBuilder
1098-
.ilike('name', `%${ name }%`)
1099+
queryBuilder = queryBuilder.ilike('name', `%${ name }%`);
10991100
}
11001101

1101-
return rxFrom(
1102-
queryBuilder
1103-
.range(from, to)
1104-
)
1102+
return rxFrom(queryBuilder.range(from, to))
11051103
.pipe(
11061104
map((x) => x),
11071105
remapErrors(),
1108-
map((x: any) => x),// map type as any , TODO: fix this
1106+
map((x: any) => x),
11091107
);
11101108
}
11111109

0 commit comments

Comments
 (0)