Skip to content

Commit 3b267e8

Browse files
author
dphuang2
committed
add logs
1 parent 24e90b4 commit 3b267e8

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

generator/konfig-next-app/src/utils/github-search-files.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,42 @@ export async function githubSearchFiles({
4242
return JSON.parse(cached)
4343
}
4444
try {
45+
console.log(
46+
`[GITHUB_SEARCH] Starting search for files with query: filename:${filename} in repo:${owner}/${repo}`
47+
)
4548
const query = `filename:${filename} repo:${owner}/${repo}`
49+
const start = Date.now()
4650
const response: SearchResponse = await octokit.search.code({ q: query })
51+
console.log(
52+
`[GITHUB_SEARCH] GitHub search API call took ${Date.now() - start}ms`
53+
)
4754

48-
console.debug('response.data', response.data)
55+
console.debug('[GITHUB_SEARCH] response.data', response.data)
4956

5057
if (response.data.total_count === 0) {
58+
console.log('[GITHUB_SEARCH] No files found matching search criteria')
5159
return null
5260
}
5361

62+
console.log(
63+
`[GITHUB_SEARCH] Found ${response.data.total_count} matching files`
64+
)
5465
const result = response.data.items.map((item) => ({
5566
name: item.name,
5667
path: item.path,
5768
url: item.html_url,
5869
}))
70+
71+
const cacheStart = Date.now()
5972
await setGithubApiCache({
6073
namespace: 'search',
6174
key: cacheKey,
6275
value: JSON.stringify(result),
6376
})
77+
console.log(
78+
`[GITHUB_SEARCH] Caching search results took ${Date.now() - cacheStart}ms`
79+
)
80+
6481
return result
6582
} catch (error) {
6683
if (error instanceof Error)

0 commit comments

Comments
 (0)