Skip to content

Commit 88ca0d3

Browse files
authored
Merge pull request #5 from attio/hotfix/linear-search
Fix project and issue search by using fuzzy search APIs rather than prefix only filter matching
2 parents 0e7e386 + 217f74a commit 88ca0d3

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
import {z} from "zod"
22

33
import {postToLinear} from "../post-to-linear"
4-
import {type LinearIssue, linearIssueFragment, linearIssueSchema} from "./schema"
4+
import {linearIssueFragment, linearIssueSchema} from "./schema"
55

66
const query = `query SearchIssues($searchQuery: String!) {
7-
issues(filter: { title: { startsWithIgnoreCase: $searchQuery } }) {
7+
searchIssues(term: $searchQuery) {
88
nodes {
99
${linearIssueFragment}
1010
}
1111
}
1212
}`
1313

14-
export default async function searchIssues(searchQuery: string): Promise<LinearIssue[]> {
14+
export default async function searchIssues(
15+
searchQuery: string
16+
): Promise<{id: string; title: string; identifier: string}[]> {
1517
const result = await postToLinear({query, variables: {searchQuery}})
1618

17-
if (result.data.issues.nodes.length === 0) {
19+
if (result.data.searchIssues.nodes.length === 0) {
1820
return []
1921
}
2022

21-
return z.array(linearIssueSchema).parse(result.data.issues.nodes)
23+
return z.array(linearIssueSchema).parse(result.data.searchIssues.nodes)
2224
}

src/linear/projects/search-projects.server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {postToLinear} from "../post-to-linear"
44
import {type LinearProject, linearProjectFragment, linearProjectSchema} from "./schema"
55

66
const query = `query SearchProjects($searchQuery: String!) {
7-
projects(filter: { name: { startsWithIgnoreCase: $searchQuery } }) {
7+
searchProjects(term: $searchQuery) {
88
nodes {
99
${linearProjectFragment}
1010
}
@@ -14,9 +14,9 @@ const query = `query SearchProjects($searchQuery: String!) {
1414
export default async function searchProjects(searchQuery: string): Promise<LinearProject[]> {
1515
const result = await postToLinear({query, variables: {searchQuery}})
1616

17-
if (result.data.projects.nodes.length === 0) {
17+
if (result.data.searchProjects.nodes.length === 0) {
1818
return []
1919
}
2020

21-
return z.array(linearProjectSchema).parse(result.data.projects.nodes)
21+
return z.array(linearProjectSchema).parse(result.data.searchProjects.nodes)
2222
}

0 commit comments

Comments
 (0)