If you’re calling a route, url_defaults ONLY runs if args are missing (and does so first). These values assert the final URL. url_route_preprocessor always runs. It does not affect the actual path (just information handling serverside).
If you’re calling url_for() to build links, only url_defaults runs; url_route_preprocessor functions do not.
Since sbsc’s resolvers on season/week/etc should ALWAYS run, they should go in defaults as well as processors. Both paths need to clean the user input. And then only the preprocessors have the expander functions, attributing additional info to g.
Hoisting highlight to the top
- Remember in general: path args are used to define which resources you’re fetching on that view. Query params are used to filter/sort/etc those resources.
- Upgraded to ios 16, can edit/unsend messages now.
- Starbucks Odyssey program, earn NFTs (“Journey Stamps”) and rewards on Polygon. Blockchain loyalty program.
- US News annual college rankings out. Overall: Princeton -> MIT -> Stanford/Harvard/Yale. Berkeley 20 overall (#1 public). Engineering: MIT -> Stanford -> Berkeley. CS: Carnegie Mellon and MIT tied for 1st, Berkeley 3rd.
- Supercontest.
- Pointed the prod app back at the espn scorestrip (last thurs), which is still fetchable now that they’ve updated.
- Successfully ran the checkout flow through stripe (last sat). Still works.
- Remember stripe takes 2.9% + 30c per transaction. So for sbsc, where a transaction is $50, our effective rate is 3.5%.
- It automatically pays out to my bank account monthly, I believe.
- Was succeeding, but still leaving an unhandled exception in the request. Triggering sentry email and bad logs. “int” is not iterable – this is because I was doing Response(200) but it needs the resp first and status second (https://flask.palletsprojects.com/en/2.2.x/api/#flask.Response) so simple change of Response(status=200).
- Added Harner to the admin list (last sun).
- System updates.
- dpkg was reporting inconsistent state for python3-apt, dpkg removed and apt reinstalled.
- Google chrome was reporting an expired signature in the apt sources list, commented out.
- Apt update and upgrade (>300 pkgs).
- Autoremove and autoclean.
- Installed the new digital ocean droplet agent so could access browser console again.
- Upgraded the droplet from ubuntu 18.04.03 to 18.04.6.
- Analytics.
- Compared Google Analytics to FlaskMonitoringDashboard.
- About 70 users last week, avg engagement time 2min.
- Most users in LA, but spread over chicago, NY, parkersburg, san jose, atlanta, all over.
- ~75% mobile.
- Overall, both are incredible tools. FMD comes with more configured out of the box, so you get rich statistic by route/user/etc with very small integration. Google requires more config to get the same (obviously, you’re going through tag instead of direct flask).
- FlaskDebugToolbar should be thrown in the conversation as well – maybe my favorite of the 3. FDT does full profiling though, db calls, everything. Actual instrumentation.
- Finished https://gitlab.com/bmahlstedt/supercontest/-/issues/151.
- Rewrote all the blueprints/routes/args.
- Moved the statistics page over to the contest views, since you have dropdown options.
- Added the dropdown options: season, user, league.
- Remember:
- url_defaults is to set values that aren’t already defined in the values dict. It’s exactly as named. If you’re calling a route, the preprocessor runs BEFORE defaults. However, url_defaults runs in all url_for() calls, whereass the preprocessor does not. So for populating all the links around the site, retaining the already-specified-args (season, league, etc), you must use defaults.
- Sidenote – that’s why you see url_defaults calls all over the logs, about 10x the logs for preprocessor runs. The frontend is building the menu links.
- url_value_preprocessor is to perform logic using the values dict. The most common case is extracting the information for use elsewhere (usually to the g object, so all routes using that preprocessor can have access to it). This runs before the route/view runs, so you can remove the args from that function if you’ve attributed them to g instead (you still need to have them in the endpoint spec of the route definition tho, of course). If you extract something from the values dict in url_value_preprocessor, just do values.setdefault(key, g.value) to reuse the g value since you already handled its logic.
- Meh, overall I hate this structure. Annoying to do on a static site. Will do it properly once a ts/react SPA. Astronomically easier to manage selections and state.
- Added a TON of cool stats views. Updating the stats logic heavily. Some interesting conclusions (all data since 2018):
- Best coverage overall: Bills (58.6%). Worst: Jets (33.9%).
- Best overperformance (points beyond line cover): Bills (3.2). Worst: Jets (-4.1).
- Largest avg line: Chiefs (-5.9). Worst: Jets (6.7).
- Our league picks chiefs the most, then rams, then pats.
- Underdog (51.5%) covers more than favorite (46.1%).
- No obvious correlation between line other variables (eg better coverage for favored team as line increases).
- The favorite covers more on thurs than sun or mon.
- Best coverage when favorite: Dolphins (61.1%). Worst: Giants (30%).
- Best coverage when underdog: Ravens (85.7%). Worst: Jets (33.3%).
- Visiting team (51.2%) covers more than home team (46.4%).
- The home team covers more on sun than thurs or mon.
- Best coverage when home team: Dolphins (67.7%). Worst: Falcons (28.6%).
- Best coverage when visitor: Bengals (67.9%). Worst: Jets (29.6%).
- Changed plotly.js to yref: paper so I didn’t have to hardcode the axis limits (mins and maxes) for the vertical line.
- found a typo (“BANGLES” lol) from westgate in 2020. run this in prod to fix.
- update lines set home_team=’BENGALS’ where id=835
- Updated banner/lines for week 2.
- Westgate/superbook did not update the redirect to week 2, AND the format of week 2’s table was different. Terrible.
- Made the full change from redskins to commanders: https://gitlab.com/bmahlstedt/supercontest/-/issues/160
- Closed the milestone: https://gitlab.com/bmahlstedt/supercontest/-/milestones/6