• Saturday

    • Remember inner join ignores nulls, so if you’re joining on a nullable column (like scores.coverer_id to teams.id), you need to do a LEFT join (if scores is on the left of the join, RIGHT if right).
    • I use 3 oils for cooking: peanut oil, olive oil, and bacon fat. Lean toward bacon whenever possible. Better flavor, 100% unrefined, etc. The most important other consideration is smoke point: bacon has the lowest, then olive, then peanut has the highest. So for panfrying something on high, must use peanut. For cooking eggs in a skillet on medium, bacon fat is fine. Olive for medium-high pan, or baking.
    • SBSC. Continued on the generated cols effort. Results views for coverer and pick points.
    • Played with sqlalchemy-utils‘ observers a bit more.
      • Confirmed that they ONLY run when the observed cols change, not on data access.
      • Confirmed that it ONLY runs in the ORM layer. If you change the observed cols in psql directly, the observer col does not update. You’d have to go the view + GENERATED AS col approach for that, but I’m fine living in python for modifications. Shouldn’t be mucking in the db anyway.
      • The observer acts as a materialized view. The col is stored. You never have to write it (it also acts as a default!). It’s avail for read.
      • You have to session.commit() to trigger, obviously, because the observer runs in the before_flush phase.
      • The only imperfection (but still liveable), with a score example: The Score.line relationship needs to exist for the Score.coverer col to be autopopulated, since it pulls from the line relationship for cols to calculate from. At at Score creation time, this isn’t the case; the line relation hasn’t been created yet, the Score is only instantiated with line_id. But that’s ok. We have the ID, we can pass the Line object. This ticket is in the business of speeding up reads not writes.
    • Made the observer columns manifest as IDs, and FK to the appropriate remote table. And then a normal sqlalchemy relationship to pull the object back for convenience use in the ORM. Very clean.