(2021-05-30) Updating WikiGraph Backlinks in Real-time

I've been updating WikiGraph every couple weeks by hand for my own stuff. But paying FluxGarden users need near-real-time BackLinks updating.

After pondering some alternatives, I think I'm going to move that BackLinks data/querying directly into WikiFlux, rather than using the outside WikiGraph service. That will also give me SSL and avoid any cross-domain issues. (I'll leave the TwinPages function over at WikiGraph for now.)

How structure the data? Have a mentions table with a row for every graph-link? Feels a little heavy/clunky....

I know PostgreSql supports JSON fields and indexed querying... ooh there's also an array field-type that might be perfect for this, because front-links are basically just a simple list of string values. And a special GIN index type instead of B-tree. And an ANY operator to use in queries. So I'm going to go this route. (Update: nope.)

Phil Jones says I should just go normalized. He's probably right.

May30

  • create table, add to model
  • manually insert some values
  • create function to query
  • remove JavaScript call from template, add block for direct Backlinks list
  • hrm why no border getting drawn?
  • more importantly, why is only 1 of the Backlinks showing up?
  • derp when I copied/pasted some model.py bits, I left one of the fields as a unique-id when it shouldn't be.
  • but now → sqlalchemy.exc.ArgumentError: Mapper mapped class Mention->mentions could not assemble any primary key columns for mapped table 'mentions'. Oh right SqlAlchemy requires a primary key. Did I mention how much I hate ORMs?

May31

  • drop/re-create table, update model → now get all 3 backlinks!
  • but still no border. Added border-style it worked, though inconsistent with the TwinPages.
  • fixed titlesearch field-hint-placeholder
  • next: save front-links mentions upon edit-save
  • have function listing all double-bracketed phrases, with the brackets, alphabetically, de-duped (but not sure about the case-sensitivity).
  • convert each of those to URL form

Jun01

  • insert front-links → working
  • delete old front-links before inserting - surprisingly hard to find the syntax for bulk deletes. Works!

Jul17

  • on Jun15 I had changed empty-page case to redirect directly to edit/create form (if the user is the logged-in owner).
  • now want to add the Backlinks box to that form (because seeing how much I reference a non-existing page affects how motivated I am to create it)... but it's generating an error
  • then I suspect the Backlinks was never working at the bottom of a non-existing page - the block is there, but with no results.... and for an existing page, I'm getting the block with no results - ah, the template includes the block, but I'm not calling the function... gotta work backwards here...
  • do I want to see Backlinks when editing an already-existing page? Sure, it adds context for the editing...
  • ok all working

Jun20

  • grr no it's not working. Saving new page breaks. Ah, because I've created a non-saved Node to attach data to, it now looks like an Update instead of a Create, which does bad things. Found better way to check, now all good.

Edited:    |       |    Search Twitter for discussion