Greenshift 019: Finishing Relationship #4

in #greenshift6 years ago

So last time, we started working on building our fourth relationship and ran into an obstacle in how resteems are stored on the blockchain. Resteems are treated as custom JSON operations rather than their own separate thing and thus we needed to do additional parsing in order to get the author and verify the operation was indeed a resteem. In the end, we found the author and now need to retrieve a permlink of their most recent piece of content.

But we already know how to do this! We simply go through the same process that we did earlier to grab the permlink using the new author and cycle through the results filtering through what we already know. The end result of rewriting this code for our new function looks like the following:


Greenshift 19-1.png

We simply take the author, find their most recent N number of operations and if a piece of content exists that has been posted in the past seven days, we grab the most recent piece of content and pass it to the controller. Speaking of the controller. Here's what it looks like now:


Greenshift 19-2.png

Note that I have increased the depth in terms of searching the blockchain up to 1000 results. This is due to the fact that resteeming is not as common as an operation as voting or posting. Unfortunately, this leaves us with the side effect of cycling through the blockchain twice 1000 times since both loops share the same variable. That's something we need to remember to fix in future iterations of the code.

Now let's look at the current state of the user interface that we have four working (but not yet optimal) relationships:


Greenshift 19-3.png

The good news is that we are now showing four pieces of content. The bad news is that there are duplicate results showing on the page. We want to give the user five fresh pieces of content to interact with, but right now we have no restrictions on the number of duplicate entries we give to the user.

So, here's the gameplan: We need to finish with our fifth relationship. That way a huge chunk of the project is finished and we can begin working on other things. But before we start working on those other things, we will review the code that we have already written and began to address some issues that are showing to pop up:

  1. A lot of the code is repetitive
  2. Some of the code is not flexible
  3. The relationships don't guarantee unique content.

Consider finishing the 5th relationship and fixing those issues a key chunk within our overall project. In software engineering once you finish certain chunk or feature of the code, you review it, try to make it better and then commit to the final result. And we're getting close to finishing this chunk.

Sort:  

This post has been just added as new item to timeline of Q-Filter on Steem Projects.

If you want to be notified about new updates from this project, register on Steem Projects and add Q-Filter to your favorite projects.