Reflect: PR2 of Release 0.3
Published: 2022-11-17 05:29:26

## The issue that I was not able to fix...
This week I made a contribution to Telescope, and this is my first-time creating a Pull Request for Telescope which means I had zero knowledge of this project regarding its system structure design and it actually caused me to under-estimate my first attempt on issue [#3639](https://github.com/Seneca-CDOT/telescope/issues/3639) which is later to be proven infeasible both for me and my co-contributor Piotr with our limited knowledge on this project. When we were first assigned this issue, we thought changing it would be as straightforward as we thought it would be if we had designed it. After a few reverse engineering from the HTTP requests of the frontend, we located the code that we need to change in the backend, however, it is not easy to change any of the data structure since the fact that this project uses many layers of data, which requires us to not only change the data field of `posts` in Radis but we also need to add a column to the database. After a few poking around, we remeasured the workload of this issue and soon found out that we might not be able to create a Pull Request to fix this issue before the due of Release 0.3 which is Nov.18th, and both of us switched to another issue. 
## The second issue I chose and how I fixed it
The second issue I chose was [#3615](https://github.com/Seneca-CDOT/telescope/issues/3615). Since my previous involvement with this project, I realized the part that I need to modify was posts.js in the Posts Service, here is how I made modified the code.
1. As per the suggested solution made by David, I added a query param `expand` to the request `/post/` to use this extra query param to control if the returned data should contain detailed information(which are author, title, and publishDate) about the feed.
2. I used an if-else statement to check if the `expand` equals 1, and if it equals 1, I will call `Post.byId(id)` on each post in the post array to query their extra information from Radis, otherwise, it will return the original data as before. The thing that I was struggling with in this step was `Post.byId(id)` is executed asynchronously, so I need to use an asynchronous function to call it. After a few google searches, I realized I could use `await Promise.all(async()=>{})` to execute this asynchronous function synchronously. 
3. Return the data that is created inside the if-else statement. 

## Post-fixing jobs
After finishing coding, I updated the document for the posts and also I wrote some tests to test my code, however, for the scenario when the request query param has `expand=1`, although this API works pretty well in actuality, the test still fails. This issue is still confusing me up until now when this reflect is written but I will find out the culprit that causes this test failure. 

**UPDATE**: I have already found the cause of this problem and fixed it. The problem appeared to be in the data of feed in each post. If I were writing feed content directly to post, it will fail since the feed object will not be recognized by `post::ensureFeed()`, the feed object will become null so the whole test will fail. To fix it, I simply replace the post's feed object with the feed id, so that `post::ensureFeed()` will always fetch the correspondent feed from  Radis.
## Thanks for our fellow developers
In the end, I want to shout out to Tue who helped us to solve the issue in which the posts don't show even though the database is already well-set. We won't be able to make the whole service run if there wasn't your help.