A decentralized music tracking and discovery platform built on AT Protocol 🎵

[api] fix directory query (dropbox/googledrive)

+14 -20
+7 -10
apps/api/src/xrpc/app/rocksky/dropbox/getFiles.ts
··· 42 42 did: string; 43 43 }) => { 44 44 return Effect.tryPromise({ 45 - try: async () => 46 - ctx.db 45 + try: async () => { 46 + const parentAlias = alias(tables.dropboxDirectories, "parent"); 47 + return ctx.db 47 48 .select() 48 49 .from(tables.dropboxDirectories) 49 50 .leftJoin( ··· 52 53 ) 53 54 .leftJoin(tables.users, eq(tables.dropbox.userId, tables.users.id)) 54 55 .leftJoin( 55 - alias(tables.dropboxDirectories, "parent"), 56 + parentAlias, 56 57 eq(tables.dropboxDirectories.id, tables.dropboxDirectories.parentId) 57 58 ) 58 - .where( 59 - and( 60 - eq(tables.users.did, did), 61 - eq(alias(tables.dropboxDirectories, "parent").path, params.at) 62 - ) 63 - ) 64 - .execute(), 59 + .where(and(eq(tables.users.did, did), eq(parentAlias.path, params.at))) 60 + .execute(); 61 + }, 65 62 catch: (error) => { 66 63 console.error("Failed to retrieve files:", error); 67 64 return new Error(`Failed to retrieve files: ${error}`);
+7 -10
apps/api/src/xrpc/app/rocksky/googledrive/getFiles.ts
··· 41 41 did: string; 42 42 }) => { 43 43 return Effect.tryPromise({ 44 - try: async () => 45 - ctx.db 44 + try: async () => { 45 + const parentAlias = alias(tables.googleDriveDirectories, "parent"); 46 + return ctx.db 46 47 .select() 47 48 .from(tables.googleDriveDirectories) 48 49 .leftJoin( ··· 51 52 ) 52 53 .leftJoin(tables.users, eq(tables.googleDrive.userId, tables.users.id)) 53 54 .leftJoin( 54 - alias(tables.googleDriveDirectories, "parent"), 55 + parentAlias, 55 56 eq( 56 57 tables.googleDriveDirectories.id, 57 58 tables.googleDriveDirectories.parentId 58 59 ) 59 60 ) 60 - .where( 61 - and( 62 - eq(tables.users.did, did), 63 - eq(alias(tables.googleDriveDirectories, "parent").path, params.at) 64 - ) 65 - ) 66 - .execute(), 61 + .where(and(eq(tables.users.did, did), eq(parentAlias.path, params.at))) 62 + .execute(); 63 + }, 67 64 catch: (error) => { 68 65 console.error("Failed to retrieve files:", error); 69 66 return new Error(`Failed to retrieve albums: ${error}`);