Merge pull request #1397 from codeflash-ai/langflow-dupes-fix
Update verify-existing-optimizations.ts
This commit is contained in:
commit
bec47e5b4b
1 changed files with 9 additions and 10 deletions
|
|
@ -70,19 +70,18 @@ export async function verifyExistingOptimizations(req, res) {
|
|||
.send({ error: `Error getting PR messages for ${repo_owner}/${repo_name}` })
|
||||
}
|
||||
|
||||
const optimizationRegex = /📄\s+(\d+,\d+%|\d+.\d+x)\s+speedup\s+for\s+(\w+)\s+in\s+(.+)/g
|
||||
|
||||
for (const message of pr_messages.data) {
|
||||
if (message.body.includes("Codeflash found optimizations for this PR")) {
|
||||
const pr_body = message.body.split("\n")
|
||||
for (const line of pr_body) {
|
||||
if (line.includes("📄")) {
|
||||
const split = line.split(" ")
|
||||
const function_name: string = split[2].replace(/`/g, "").trim()
|
||||
const file_path: string = split[4].replace(/`/g, "").trim()
|
||||
if (!optimizations_dict[file_path]) {
|
||||
optimizations_dict[file_path] = new Set()
|
||||
}
|
||||
optimizations_dict[file_path].add(function_name)
|
||||
let match
|
||||
while ((match = optimizationRegex.exec(message.body)) !== null) {
|
||||
const function_name: string = match[2].replace(/`/g, "").trim()
|
||||
const file_path: string = match[3].replace(/`/g, "").trim()
|
||||
if (!optimizations_dict[file_path]) {
|
||||
optimizations_dict[file_path] = new Set()
|
||||
}
|
||||
optimizations_dict[file_path].add(function_name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue