Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/slack/commands/list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { eq } from 'drizzle-orm'
import { eq, sql } from 'drizzle-orm'
import { buildListBlocks } from '@bot/blocks/list'
import { db } from '@db/client'
import { repositories, subscriptions } from '@db/schema'
Expand All @@ -21,6 +21,10 @@ export async function handleList(
.from(subscriptions)
.innerJoin(repositories, eq(subscriptions.repositoryId, repositories.id))
.where(eq(subscriptions.channelId, ctx.channelId))
.orderBy(
sql`lower(${repositories.owner})`,
sql`lower(${repositories.repo})`,
)
Comment on lines +24 to +27

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just let me know if this is how you want it to be sorted.


if (rows.length === 0) {
await ctx.respond(
Expand Down
7 changes: 7 additions & 0 deletions src/slack/commands/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,11 @@ describe('parseRepo', () => {
test('returns null for empty string', () => {
expect(parseRepo('')).toBeNull()
})

test('lowercases owner and repo', () => {
expect(parseRepo('Torvalds/Linux')).toEqual({
owner: 'torvalds',
name: 'linux',
})
})
})
5 changes: 4 additions & 1 deletion src/slack/commands/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ export function parseRepo(arg: string): { owner: string; name: string } | null {
}

const idx = arg.indexOf('/')
return { owner: arg.slice(0, idx), name: arg.slice(idx + 1) }
return {
owner: arg.slice(0, idx).toLowerCase(),
name: arg.slice(idx + 1).toLowerCase(),
}
}