Skip to content

Commit 4e57e9d

Browse files
authored
Merge pull request #19 from yogesh-aggarwal/chore/refactor
chore: missing code organization techniques in ingestion server
2 parents 5a1f346 + 8693cf8 commit 4e57e9d

26 files changed

+1117
-205
lines changed

ingestion/.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"explorer.fileNesting.enabled": true,
3+
"explorer.fileNesting.patterns": {
4+
"package.json": "package-lock.json, .env, .env.example, .gitignore, .prettierrc, Dockerfile, nodemon.json, tsconfig.json, *.lock, README.md",
5+
"*.ts": "$(capture).*.ts"
6+
}
7+
}

ingestion/bun.lock

Lines changed: 814 additions & 0 deletions
Large diffs are not rendered by default.

ingestion/bun.lockb

-139 KB
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { RC_APP_URI } from "@/core/constants"
2+
import { CodeModelRelation } from "@/models/code"
3+
4+
export async function establishRelations(relations: CodeModelRelation[]): Promise<boolean> {
5+
try {
6+
const res = await fetch(`${RC_APP_URI}/establishRelations`, {
7+
method: "POST",
8+
headers: {
9+
"Content-Type": "application/json",
10+
},
11+
body: JSON.stringify({ relations }),
12+
})
13+
14+
return res.status === 200
15+
} catch (e) {
16+
console.log(e)
17+
return false
18+
}
19+
}

ingestion/src/api/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { purgeDB } from "./purge-db"
2+
export { insertBatch } from "./insert-batch"
3+
export { establishRelations } from "./establish-relations"

ingestion/src/api/insert-batch.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { RC_APP_URI } from "@/core/constants"
2+
import { CodeModel } from "@/models/code"
3+
import { DocumentationModel } from "@/models/devdoc"
4+
5+
export async function insertBatch(batchID: string, nodes: (CodeModel | DocumentationModel)[]): Promise<boolean> {
6+
let tries = 5
7+
while (tries--) {
8+
try {
9+
const res = await fetch(`${RC_APP_URI}/ingest`, {
10+
method: "POST",
11+
headers: {
12+
accept: "application/json",
13+
"Content-Type": "application/json",
14+
},
15+
body: JSON.stringify({ nodes, batchID }),
16+
})
17+
18+
if (res.status !== 200) {
19+
console.log(res)
20+
return false
21+
}
22+
23+
return true
24+
} catch (e) {
25+
console.log(e)
26+
}
27+
}
28+
return false
29+
}

ingestion/src/api/purge-db.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { RC_APP_URI } from "@/core/constants"
2+
3+
export async function purgeDB(): Promise<boolean> {
4+
try {
5+
const res = await fetch(`${RC_APP_URI}/purgeDB`, {
6+
method: "POST",
7+
headers: {
8+
accept: "application/json",
9+
"Content-Type": "application/json",
10+
},
11+
})
12+
13+
return res.status === 200
14+
} catch (e) {
15+
console.log(e)
16+
return false
17+
}
18+
}

ingestion/src/core/dbNode.ts

Lines changed: 0 additions & 76 deletions
This file was deleted.

ingestion/src/core/devDocDBNode.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)