what i did today

338/365

My favorite thing about commuting via Tokyo public transportation is that delays are inevitable, especially on high-congestion lines like mine. I was up early. I left the house early. But, for reasons unknown to me, I was 5 minutes late. Thankfully, my train car wasn't as crowded as it usually is, so I was able to breathe comfortably as we paused between stations for minutes on end. Travelling mercies, as my aunt would say.

I finally finished a task at work that had been lingering in my backlog for about a month. My first attempt worked but was rejected after code review with little explanation beyond, "No." So, I dropped it in favor of more interesting tasks since it wasn't a high priority. Coming back to it from the high of a successful feature launch and a clear mind was the right call; I could see the problem clearly. The wind was at my back. All it took was a little refactor here, some simplification there, and I arrived at an even better solution.

The customer had asked that, after deleting a record, they be returned to the search page in the state that they had left it. This is actually a very simple problem to solve in Django, as all logic could be handled in the view function. However, in our codebase, we needed to find a workaround that did not require editing the original delete view function. Instead, I replicated what I think would be going on under the hood in ~123 lines of Javascript in the search page HTML template. In pseudo-code, the logic goes as follows:

// save all search form data on submit and save that data object in sessionStorage
// on 'beforeunload,' mark the saved search data for restoration
// when returning form the page
  // - restore saved search data on page load
  // - restore form field data
  // - remove saved search data from sessionStorage
  // - run search again

There's also some flags to keep track of whether the page data is being restored from the session, whether the form is being submitted, and if a search query has been submitted. These help avoid infinite loops. Overall, this is a nice solution and can be easily replicated across the codebase. Though it was not my first choice, I am pleased with the outcome.

Healing from my wisdom tooth extraction has been another beast entirely. Apparently, this surgery was a little more complicated than the last one and I think I can tell. One section of my lip is completely numb and the pain is much worse than last time.

At this point, all I want is to be healed enough to do my traditional New Year's Day hike. I'm not sure which trail I'll visit this time. I want one that is more scenic than difficult, but I also want a big shrine close by so I can get some festival food and maybe a prayer. It's times like these when I miss Awajishima the most. Tokyo is very convenient for many things, but it is so difficult to access nature. Forgoing the outdoors is a natural concession for me to make to live in the largest metropolis in the world, but I miss it something fierce. Nothing hits like a woodland trek after sitting at a desk all day.

#log #work