- Supercontest.
- Made the leaderboard current_user row highlight with border like the picks current_user row.
- Standardized all the flask_user templates. Made them extend my bases, so the headers are consistent throughout the whole site.
- Changed all the container/row/cols to be more responsive, and optimized for different viewports.
- Changed the matchups table to white-space:nowrap. This was specifically for the datetime column, but applies to all cols and all rows. Nothing should span two lines. As the viewport shrinks, it should scroll overflow.
- Added make enter-dev/prod-app for ease.
- A recent alembic migration had iteritems(), had to upgrade to items() now that the app is py3.
- Deleted all remote branches and pruned refs.
- Deployed the cosmetic and responsive changes from the first #68 branch.
- Backed up before all prod changes to be sure.
- Migration:
- Pluralized table names for easy querying.
- Dropped default values for user cols: email, is_active, password.
- Made user cols nullable: first_name, last_name.
- Set the val/nextval in the sequences for all 3 tables to match max(id).
- Merged and deployed the changes to the existing db first. Adding new season table and all the others next.
- Made logout tab dynamically change to login based on auth state.
- Gigantic table redesign (full source changes to the model captured here https://github.com/brianmahlstedt/supercontest/commit/0684fdc731d975bbdb80a8a961cc2d83cda1aea2):
- New Season table, with sequence on id. year col, int, not nullable.
- Add seasons col to User table, many-many relationship with Season. Unidirectional.
- New Week table, with seq on id. Two col, season_id (fk), and week. Both ints, both non nullable.
- Rename Matchup to Line table. Include sequence. id, season_id (fk), week_id (fk), favored_team, underdog_team, datetime, line, and home_team moved. The favored_team_score, underdog_team_score, and status cols moved to the new Score table. Winner moved to a new Coverer table. home_team became nullable=False.
- The Pick table lost its season and week cols. It now uses a foreign key to the line table for the id of the matchup that contained the team it picked. Also dropped the points col (did not move). The cols user and line became not nullable.
- New Score table. Id pk with seq. Line_id, fk, int, not nullable. Moved favored_team_score and underdog_team_score and status from the old matchups table here, and made them not nullable.
- I had initially created PickPoints, WeekPoints, and SeasonPoints tables, but I think it’s better to recalc than to aggregate and store. This is a design decision based on application usage. Scores can change 3 days out of the 7. If ever a score changes, the points for that pick changes, which requires a recalc of PickPoints, WeekPoints, and SeasonPoints. So storing the calc output doesn’t really save much. If you data is more static, then it’s better to store the calcs.
- You can customize the graphiql template, but it’s not easy. Flask-graphql allows you to pass a template string, but it’s a full react app, so you can break it quite easily. I would have to copy over the jumbotron and settings_navs manually, since jinja can’t integrate them, so I’ll leave it as-is.
- Watched the rob lowe and bruce willis roasts in the background while working. The new alec baldwin roast is coming up this sunday.
- Upgraded the mint link to BoA.
- col, col-12, and col-xs-12 are all the same thing. xs and 12 are the defaults. The breakpoint setting (the viewport size) is, remember, a minimum, so it applies to all screens that are larger. Therefore they all mean one column, across the full width, on all screens.
- Flask-sqlalchemy will autoincrement the first primary key with integer type.
- Coordinated with Roubik (Nel’s dad), going to meet Thursday in Glendale.
- A tablespoon of my homemade tahini in a big cup of coffee = delicious. Adds some good fats and a nutty flavor.
- Placed Fresh order.
- Useful psql:
- List all sequences:
- select c.relname from pg_class c where c.relkind = ‘S’;
- List all defaults:
- select column_name, column_default from information_schema.columns where (table_schema, table_name) = (‘public’, ‘<mytable>’) order by ordinal position;
- Drop a default:
- alter table public.<table> alter column <column> drop default;
- List cols as nullable or not:
- select table_name, column_name, is_nullable from information_schema.columns where table_name = ‘<mytable>’;
- List indexes:
- select * from pg_index where tablename not like ‘pg%’;
- Remember, don’t execute crucial sql in the database without including it in the alembic upgrades/downgrades. You can put arbitrary op.execute(<sql>) to make sure that all you manual actions are captured programmatically.
- It is understandable, but still kinda sucks how manual db migrations still are. Alembic can’t auto-understand every change to your model, especially when abstracted away through an ORM like sqlalchemy, and flask-sqlalchemy.
- Basic relationship patterns: many-one, one-many, one-one, many-many.
- For many-one or one-many, you simply specify a foreign key to another table (usually pulling in the id). If you want actually attribute the whole row (like make all the children available in the parent object), then specify the FK as well as a relationship with back_populates. You can go both directions.
- One-one is easy. It’s just many-one or one-many with uselist=False, where you simply attribute a scalar for the parent/child instead of many.
- Many-many isn’t that bad. You require an extra table called an association table which connects the column in each of the left and right tables that you want to map. Then you simply reference the association table in each of the two tables you want to associate. You put in both if you want bidirectional (ie child object has parents col and parent obj has a children col), or you can only put it in one if you want.
- I want to smoke a big rib roast next time. This is basically the same meat as the ribeye (the best steak), but in a much larger roast cut instead of a steak cut. Slices of a big rib roast are what prime rib is.
- It is very expensive, obviously. Even a good cheap distributor is gonna charge $15-20/lb for a prime rib roast. Wagyu ribeye can be over $100/lb.
- Costco sells a boneless 7lb for $130.
- Art mentioned biologics and biosimilars: https://www.phrma.org/advocacy/research-development/biologics-biosimilars.
- Did another domain scrape. curebench and pillemporium are both available. I love em.
- When designing the models, you can just put the foreign key IDs without backpopulation/backref. This keeps your tables leaner, but it makes your queries heavier (because you have to join). This is obvious, but is a pretty important decision when designing a system.