Repository
https://github.com/lion-200/CurationAssistant
What is Curation Assistant?
As I already explained in my initial introduction post:
Curation Assistant is an "assistant" for the curator to help him/her out by checking some basic rules defined by the curator. The intention of Curation Assistant is to reduce the time spent on checking administrative facts, so that the curator can have more time to curate good stuff, which is good for the whole community. This project is set up generic, so that it can be used by more curator groups like
,
,
etc.
New Features & important changes
I have implemented the following features and important changes as already defined in the Roadmap of my introduction post.
- Major change: Combining the power of Hivemind & Steem API's
- Feature: Rule for min amount of days since last upvote
- Feature: Most Recent upvotes from upvote account
Major change: Combining the power of Hivemind & Steem API's
Description
I explained in my previous dev post that Steem API endpoints sometimes do not give the desired result in the most efficient way. For example, for one of the features I wanted to implement, I wanted to get the last time the upvote account has voted for the author. If you want this information from the API's of Steem, you basically need to go through all the votes of the upvote account in decreasing order until you find an upvote. And you need to think of scenario's like if the author never received an upvote yet, for which you must set a certain limit to process the results. First of all, this action takes a lot of time, secondly the use of resources is not optimal to achieve the desired result.
For more features like the one I explained above, there is a need of a lookup in a db table for example instead of processing large api responses.
The most used DB solutions in Steem are SteemSQL and Hivemind. Because I don't have regular funds for this tool, I chose for the free option Hivemind instead of the paid subscription SteemSQL. Although SteemSQL would suit better because it is based on MSSQL and my application is a C# application, the paid subscription was a no-go for me unfortunately.
I installed and configured Hivemind to run on a linux server, and created a link to the Hive DB from my application. The steps of setting up hivemind can be found on posts related to hivemind.
In order to connect my application to the Postgresql database of hivemind, I used the NuGet package called NpgSql.
Before hivemind my application was a single layer application, but now that I also have a DB behind it, I decided to create 2 more layers to make it a 3-layer application consisting of:
- Data layer
- Service layer
- Web layer
Below I explain what I have implemented in each layer.
Data layer
In this layer I define the database tables as entities in my application.
For each database table, there is an entity class defined in this layer.
For each property of each class I had to check the postgresql table definitions to give the fields correct types like string, DateTime etc.
All entities can be found under Models folder:
The definition of the data context happens in HiveContext class.
I had some troubles with the entities because not all table in Hive db contain a primary key, which is required by Entity framework in .NET. I solved this by combining fields to define the primary key for those tables. Below you can see the content of this file.
Service layer
In this layer, I created a DTO class for each data entity in Data layer. These DTO classes can be found under Models folder.
And then I created services and service interfaces for the entities. Instead of creating a service for each entity, I tried to combine some entities in one service to keep the logical entities together. For example the PostService will contain operations for entities PostCache, Post, PostTag.
The mapping of properties from Entities to DTO's and vice versa is handled by AutoMapper. This is a useful package I used before for other projects, taking care of mapping of properties between two classes. As long as the property names are the same, the following configuration is sufficient. Of course, you can also map properties with different name.
Web layer
The idea in 3-layer applications is that Web layer asks data from Service layer, which gets the data from Data layer and gives back to Web layer, which results in separation of concerns.
Each layer has its own responsibility.
To get any result we simply need to create the necessary method in service layer and make a call from web layer to the service layer to retrieve the data delivered in DTO's.
In order to keep dependencies between layers and objects as low as possible, I also implemented dependency injection by using Unity in my application.
Now the only thing necessary is link web layer to service layer by injecting the needed service in the constructor of the controller being used, in this case the Home controller:
Feature: Rule for min amount of days since last upvote
This rule is to check when the last time was that the upvote account has voted the author of the post. Now that we have a DB in place, we can easily check this by looping through the posts of the author and returning the ones where the upvote account is in the voters list. Although this can be achieven much much more efficiently, current Hive DB stores the voter information in PostCache table under votes field which is a string.
Here you can see the db query in Service layer PostService class:
Here you can see the call from the Web layer to the service method we created:
Here you can see possible results on the web page:
Feature: Most Recent upvotes from upvote account
In order to give the curator more information, I retrieve the most recent x upvotes from the upvote account to the author in the Author details section of the page.
This information gives the curator extra insight in the most recent upvotes the author has received. Sometimes the upvote account like curie gives a smaller upvote to a post, this can be visible on this list.
How to contribute?
For Backend as well as Frontend you are welcome to contribute to this project.
I am a C# .NET backend developer for more than a decade. Although I do some frontend work too, my skills and interests lie more on the backend.
The projects I have worked on and currently I am working on are Web projects for mostly internal use for the companies I work(ed) for. That's why putting a lot of things I did on Open Source was not an option.
I will post more of my work (which can be shared) via my GitHub repo in the future.
List of commits
Since there are no other developers involved, I include here the commits I directly have made to GitHub.
https://github.com/lion-200/CurationAssistant/commit/c955070961294d44635b6de715625917d6ca113c
https://github.com/lion-200/CurationAssistant/commit/b8b5c21cc32a4efdedf7673394def69911582961
https://github.com/lion-200/CurationAssistant/commit/44ae09983d88fea410a92b19a2cf7dfcf3667be5
https://github.com/lion-200/CurationAssistant/commit/30fa156d951e7b13117b7631c8c6294f8d6c831a
https://github.com/lion-200/CurationAssistant/commit/05a79d5b43bee5cc4f4cb65c93ca5d5b973029a6
https://github.com/lion-200/CurationAssistant/commit/97811953ff663871e0f13785878f6fc7d16edb12
https://github.com/lion-200/CurationAssistant/commit/5ddf706e5977a6aafcc11c0de4b5b4ec247c7cd0
https://github.com/lion-200/CurationAssistant/commit/f629edd05b84e04c148c1ba3e2fe1a7aeb9f0130
https://github.com/lion-200/CurationAssistant/commit/dabae67a1bc50d921846161dd8842e50c31bc66d
https://github.com/lion-200/CurationAssistant/commit/8d0ae07e9f9fbe006713cf44e62cbdc9a5927019
https://github.com/lion-200/CurationAssistant/commit/6921a29099c7ccf6b64738aa7d4a33afef355951
https://github.com/lion-200/CurationAssistant/commit/9ff6aa5f59d3d0464efc4a65f5a1bdf6841b3ae9
Roadmap
Rule for total pending payout of the authorRule for minimum amount of days ago the author received a big upvoteRule for min amount of days since last upvoteI also consider using other sources (like SteemSQL or hivemind) besides the Steem API. There are also other alternatives like streaming the blockchain and store the data I use in the app.Most Recent upvotes from upvote account- SteemConnect or other type of authentication
- Adding functionality to upvote a post right from the tool
- SSL certificate for the website url
Ways to reach me?
Steem account obviously:
Discord channel: Curation Assistant (https://discord.gg/bmJFXn)
Discord account: @Lion_200
E-mail: lion200.dev@gmail.com or info@curationassistant.com