DPS911 Blog #12: The beginning of the end
Tags: opensource
Published: 2021-04-10 02:33:14

Only 2 blog posts until I can stop writing these things...thank god.
Well, maybe I'll drop the odd post here and there!

After last week's bout, things sorta resolved themselves just nicely. With less school work to do this week, this was the week I've been waiting for to really just relax and take some time to look after myself, which included going for some walks. The weather was amazing this week, you can hardly blame me for that.

In terms of reviews, I got back to doing them, and I did alot. David ended up bearing the bulk of PRs I reviewed this week since the main story was getting a fully functional user service. That, and some other fixes related to our staging and production servers. Talking about all of them would mean I'd be writing this blog post forever, so here's a list of all the PRs he made that I reviewed:

* [Use hashed email as the id for users in firestore](https://github.com/Seneca-CDOT/telescope/pull/2060)
* [Increased letter spacing for telescope-post-content](https://github.com/Seneca-CDOT/telescope/pull/2061)
* [Rework User to use proper JWT payload data](https://github.com/Seneca-CDOT/telescope/pull/2088)
* [Remove /myfeeds page, components, and deps](https://github.com/Seneca-CDOT/telescope/pull/2089)
* [Fix login on localhost, add WEB_URL env variable support](https://github.com/Seneca-CDOT/telescope/pull/2098)
* [Allow Vercel preview PR URLs for auth redirects on staging](https://github.com/Seneca-CDOT/telescope/pull/2099)
* [Don't use / as webUrl, prefer NEXT_PUBLIC_WEB_URL or VERCEL_URL](https://github.com/Seneca-CDOT/telescope/pull/2104)
* [Don't assume https:// for WEB_URL](https://github.com/Seneca-CDOT/telescope/pull/2107)

These weren't the only PRs I reviewed of course. Today, I was with David helping Ilya get his search service ready to be merged in. This was a service we've been waiting for quite some time, as I had a PR that was blocked (This PR was [here](https://github.com/Seneca-CDOT/telescope/pull/2012), however, like with the jest timeout PR I had, rebasing master onto here ended up closing the PR altogether. Good riddence I say, that was the last of my PRs with messed up timeframe of commits and the temporary fix was merged in by Josue not too long ago. I'll file a new PR to get this sorted out next week). Calvin's parser service also landed today, which means that all of the microservices we've been developing since 1.8 have now finally all landed.

I also did a number of reviews for some front-end related PRs. Namely, two from Yuan, which were the following:

* [Add link colors to palette; change link color in dark mode about page](https://github.com/Seneca-CDOT/telescope/pull/2082)
* [Only show navbar when scrolls to post](https://github.com/Seneca-CDOT/telescope/pull/2094)

She also that [this PR](https://github.com/Seneca-CDOT/telescope/pull/2081) that I reviewed as well to update our environment-setup docs to reference that they now use microservices. A good change, and one that will probably be changed again once the backend code is fully removed.

The more complicated PR was [this one by Minh](https://github.com/Seneca-CDOT/telescope/pull/2005). He's updating the SearchBar design, and this means he needs to tweak with the new Search Context values that I provided in the new SearchProvider. The updates have been very slow, but since he's using logic that I made, I was able to provide my most extensive review ever on a PR. I think I've requested more changes in this PR alone, than I have in any PR I've wrote or reviewed this entire semester. His PR has been sitting for almost a month now and we can't have PRs sit in hell for that long of a time, so we're splitting parts of his code into another issue so we can land his PR in time for 2.0.

As for work that I did, well, I had a couple of PRs that got in successfully. My SearchContext bug was resolved, and it finally got merged in. You can find that PR [here](https://github.com/Seneca-CDOT/telescope/pull/2066). 

I also updated the jest e2e timeout settings so that our github actions don't timeout on the end-2-end tests and randomly fail CI for whatever reason. You can find that PR [here](https://github.com/Seneca-CDOT/telescope/pull/2092)

My big PR for this week, however, came in today after starting on it yesterday. Mo had two tasks on Satellite, of which, he was focused on the caching, while the other, the porting of redis, was sitting for a long time. I asked him if he was going to continue on with that, to which he mentioned that he didn't have the time. Knowing that my service, and Calvin's parser service needed redis in satellite, I finally decided to fork Satellite over and complete the port with his permission. I got a PR up with most of the code working, but the tests hanging up. While working with Ilya with his search service, I got some time with David to help debug this, and it essentially came down to how I was turning on and turning off redis.


![Redis test code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nx912mpjddsx9t72ru4l.png)

The afterEach made alot of sense. Using redis.disconnect() would not work here, because the test would run again and fail due to a connection being terminated. So I had to use redis.quit(). The real issue was in my beforeEach. Starting the redis server here was tough. So on David's advice, I made the following changes in the redis.js file:

![Updated RedisConstructor function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wpe7xlmkopgvgficclzm.png)

The try/catch was removed, the password code was removed, and I passed an options object to the function that returns a new redis constructor, using the REDIS_URL and the options object. In the test case, I called the createClientFunction in my beforeEach, and then, I used the done function that jest provides. It's an awesome function that helps with ensuring that asynchronous connections are properly handled with. I never wrote database tests before, so this is something I was amazed with. The redis test itself was very basic, just a simple redis ping command that returns "PONG". Applying the changes, and bam! The test closed up perfectly with no problems. A push and merge later, and I was good to go. I did rob Chris the chance to review it since I merged it without any reviews, which again, I need to stop doing. I have this feeling where if something's watching me code and it works fine, then I can just merge it in no questions asked. This is what let me to my problems last week, and luckily, that didn't occur this time. Satellite was updated and redis is now available publicly for all services that need it.

I wrapped up this week by reviewing and approving a PR by Josue to add the search service's correct values to our staging and production environment values. You can find this [here](https://github.com/Seneca-CDOT/telescope/pull/2113).

The two main issues I want to tackle for next week are the health check for the post service (https://github.com/Seneca-CDOT/telescope/issues/1938) and the search service being used in the front-end (https://github.com/Seneca-CDOT/telescope/issues/2014). These issues should be simple enough to get in so I'll try and see if I can start them early on Sunday since I'll be busy with work this weekend. With our second-last update in, alot of PRs will be rushed in the next 2 weeks. 2 more weeks to go before my journey in open-source is on a pause. Until next week, see you guys next time!


A small PS: I got Ramadan next week starting on Monday most likely, which means I'm gonna be fasting for the next month starting next week. Happy Ramadan to all observing! This government shutdown and pandemic cannot come soon enough.