Skip to content

Commit 94d8c69

Browse files
committed
Fixed insertIntoDB function
1 parent 57bc620 commit 94d8c69

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

rocket-chatter-ingestion-server/src/process/ingest/ingest.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import cliProgress from "cli-progress"
22
import { readdirSync } from "fs"
33
import { readFile } from "fs/promises"
44
import { Transaction } from "neo4j-driver"
5+
import path from "path"
6+
57
import { DBNode } from "../../core/dbNode"
68
import { db, verifyConnectivity } from "../../core/neo4j"
79

@@ -97,13 +99,16 @@ namespace Algorithms {
9799
}
98100
}
99101

100-
export async function insertDataIntoDB(batchSize: number = 50) {
102+
export async function insertDataIntoDB(
103+
embeddingsPath: string,
104+
batchSize: number = 50
105+
) {
101106
console.log(await verifyConnectivity())
102107

103108
console.log("🕒 Inserting")
104109

105-
const files = readdirSync("./data/embeddings").map(
106-
(file) => `./data/embeddings/${file}`
110+
const files = readdirSync(embeddingsPath).map((file) =>
111+
path.resolve(embeddingsPath, file)
107112
)
108113
const totalNodes = files.length * batchSize
109114

rocket-chatter-ingestion-server/src/process/prepare/codebase.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ export class Codebase {
4545
this.makeFilesBatches()
4646
}
4747

48+
get embeddingsDirPath(): string {
49+
return this._embeddingsDirPath
50+
}
51+
4852
private initializeDataDirectory(removeExisting = true): void {
49-
this._dataDirName = `data-${Date.now()}`
53+
this._dataDirName = `data`
5054
this._dataDirPath = path.resolve(this._path, this._dataDirName)
5155

5256
this._embeddingsDirName = `${this._dataDirName}/embeddings`

rocket-chatter-ingestion-server/src/use.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { Codebase } from "./process/prepare/codebase"
22
import { FileProcessor } from "./process/prepare/processor/file"
33

44
async function main() {
5-
const codebase = new Codebase("./project", new FileProcessor())
5+
const codebase = new Codebase("./project", new FileProcessor(), 1)
66
await codebase.process()
7-
await codebase.embed()
7+
// await codebase.embed()
8+
9+
// insertDataIntoDB(codebase.embeddingsDirPath, 1)
810
}
911

1012
main()

0 commit comments

Comments
 (0)