Skip to content

Commit

Permalink
put it all together
Browse files Browse the repository at this point in the history
  • Loading branch information
stevencohn committed Apr 24, 2024
1 parent 1b1efb9 commit 8862571
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 33 deletions.
51 changes: 37 additions & 14 deletions OneMore/Commands/Tagging/HashtagScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,31 +140,54 @@ public void Dispose()
var notebooks = root.Elements(ns + "Notebook");
if (notebooks.Any())
{
var knownNotebooks = provider.ReadKnownNotebookIDs();

foreach (var notebook in notebooks)
{
// gets sections for this notebook
var notebookID = notebook.Attribute("ID").Value;
var name = notebook.Attribute("name").Value;

if (notebookFilters is null ||
notebookFilters.Contains(notebookID))
var scanned = false;

// Filter on two levels...
//
// knownNotebooks
// If knownNotebooks is empty, then we assume that this is the first scan
// and will allow all; otherwise we only scan known notebooks to avoid
// pulling in large data from newly added notebooks - user must schedule
// a scan to pull in those new notebooks explicitly.
//
// notebookFilters
// If notebookFilters is empty then allow any notebook that has passed the
// knownNotebook test; otherwise, the user has explicitly requested a scan
// of notebooks specified in the notebookFilters list.
//

if (knownNotebooks.Count == 0 ||
knownNotebooks.Contains(notebookID))
{
//logger.Verbose($"scanning notebook {notebookID} \"{name}\"");

var sections = await one.GetNotebook(notebookID);
if (sections is not null)
if (notebookFilters is null ||
notebookFilters.Contains(notebookID))
{
var (dp, tp) = await Scan(one, sections, notebookID, $"/{name}");
//logger.Verbose($"scanning notebook {notebookID} \"{name}\"");

dirtyPages += dp;
totalPages += tp;
}
var sections = await one.GetNotebook(notebookID);
if (sections is not null)
{
var (dp, tp) = await Scan(one, sections, notebookID, $"/{name}");

provider.WriteNotebook(notebookID, name);
dirtyPages += dp;
totalPages += tp;
}

provider.WriteNotebook(notebookID, name);
scanned = true;
}
}
else

if (!scanned)
{
//logger.Verbose($"skipping notebook {notebookID} \"{name}\"");
logger.Verbose($"skipping notebook {notebookID} \"{name}\"");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion OneMore/Commands/Tagging/HashtagsDB.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CREATE TABLE IF NOT EXISTS hashtag_scanner (scannerID INTEGER PRIMARY KEY UNIQUE NOT NULL, version NUMERIC (12) UNIQUE NOT NULL, scanTime TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS hashtag (tag TEXT NOT NULL, moreID TEXT NOT NULL, objectID TEXT NOT NULL, snippet TEXT, lastModified TEXT NOT NULL, PRIMARY KEY (tag, objectID), CONSTRAINT FK_moreID FOREIGN KEY (moreID) REFERENCES hashtag_page (moreID) ON DELETE CASCADE);
CREATE TABLE IF NOT EXISTS hashtag_page (moreID PRIMARY KEY, pageID TEXT NOT NULL, titleID TEXT, notebookID TEXT NOT NULL, sectionID TEXT NOT NULL, path TEXT, name TEXT);
CREATE TABLE IF NOT EXISTS hashtag_notebooks (notebookID TEXT PRIMARY KEY, name TEXT);
CREATE TABLE IF NOT EXISTS hashtag_notebook (notebookID TEXT PRIMARY KEY, name TEXT);
CREATE INDEX IF NOT EXISTS IDX_moreID ON hashtag (moreID);
CREATE INDEX IF NOT EXISTS IDX_pageID ON hashtag_page (pageID);
CREATE INDEX IF NOT EXISTS IDX_tag ON hashtag (tag);
Expand Down
36 changes: 18 additions & 18 deletions OneMore/Commands/Tagging/ScheduleScanDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8862571

Please sign in to comment.