Skip to content

Commit

Permalink
Merge pull request #23 from ubeF/remove-caching
Browse files Browse the repository at this point in the history
force clear database
  • Loading branch information
ubeF authored May 2, 2024
2 parents bec2bc8 + 279fa3f commit 39664b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
16 changes: 1 addition & 15 deletions lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Database {
}

async prepare(url) {
await this.migrateData(); // To do: add option to utilize existing page-information
await this.clearData();

let { records, summary } = await this.driver.executeQuery(
`CREATE (:Page {url: $url, depth: 0, expanded: false})`,
Expand All @@ -29,17 +29,6 @@ class Database {
);
}

async migrateData() {
let { records, summary } = await this.driver.executeQuery(
`
MATCH (p:Page)
SET p.depth = null
`,
{},
this.context
);
}

async clearData() {
let { records, summary } = await this.driver.executeQuery(
`MATCH (n) DETACH DELETE n`,
Expand All @@ -63,9 +52,6 @@ class Database {
{ srcURL, trgtURL, depth },
this.context
);

const numNodesCreated = summary.counters.updates()["nodesCreated"];
return numNodesCreated === 0;
}

async getPages(depth, maxNumItems) {
Expand Down
12 changes: 1 addition & 11 deletions lib/hiker.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,10 @@ async function expandURL(url, options) {

const references = await options.getReferences(url);
for (const ref of references) {
const hitKnownNode = await options.database.addReference(
url,
ref,
options.level + 1
);
await options.database.addReference(url, ref, options.level + 1);
if (ref === options.target) {
return true;
}
if (hitKnownNode) {
const route = await options.database.getRoute(ref, options.target);
if (!!route) {
return true;
}
}
}
await options.database.setPageToExpanded(url);

Expand Down

0 comments on commit 39664b5

Please sign in to comment.