Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force clear database #23

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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