Curation Assistant v2.0: Major changes (Hivemind & Steem API's) & New features! Helpful tool for curation!

in utopian-io •  6 years ago  (edited)

Repository

https://github.com/lion-200/CurationAssistant

What is Curation Assistant?

Logo-trans-hor.png
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 @curie, @ocd, @c-squared 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.

10.png

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:

20.png

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.

30_2.png

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.

40_2.png

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.

50_2.png

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.

60.png

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:

70_2.png

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:

80.png

Here you can see the call from the Web layer to the service method we created:

90.png

Here you can see possible results on the web page:

100.png
110.png

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.

120.png

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 author
  • Rule for minimum amount of days ago the author received a big upvote
  • Rule for min amount of days since last upvote
  • I 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: @lion200
Discord channel: Curation Assistant (https://discord.gg/bmJFXn)
Discord account: @Lion_200
E-mail: [email protected] or [email protected]

GitHub Account

https://github.com/lion-200

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Hello there. Thank you for your contribution. You seem to have done quite a lot of work implementing some cool features. Well done. I took up your contribution because some of the dev mods were unavailable. Anyways, I wish you great success with your project.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Hi! Thanks a lot! :)

Posted using Partiko iOS

Thank you for your review, @knowledges! Keep up the good work!

Good work man, having a look right now

Thanks a lot :) Need to do some performance improvements still, but I released it as is to let people use the available functionalities.

Always open for suggestions ;)

Posted using Partiko iOS

#utopian-io has been a gift. We would like to keep its curation-efforts alive here on 'marlians.com'. We want to curate and reward 'contributions to open-source projects' with MARLIANS on the the marlians.com tribe, a SCOT-enabled steem condenser. Contributions can include suggestions, graphics, bug-finds, code etc. You can simply add in #marlians to your #utopian-io posts and it will appear on https://www.marlians.com/created/utopian enabling you to earn some MARLIANS along with steem/sbd. You can also post directly to steem via 'marlians.com'. We have some overseers who curate and who can render you help too. You can find them enlisted on https://www.marlians.com/created/utopian

Heyy @surpassinggoogle, thanks for dropping by. I will add the marlians tag to my next contribution. Thanks a lot for the support!

Hi bro, thanks. I know devs usually have not much time. I was wondering if you can take a look at some tasks I have. The tasks are simple and has small bounty mostly for inspiration.

https://github.com/steem-engine-exchange/nitrous/issues/69
https://github.com/steem-engine-exchange/nitrous/issues/55
https://github.com/steem-engine-exchange/nitrous/issues/46

Heyy there,
I will take a look at the tasks as soon as I'm available ;)
Thanks!

Hey, @lion200!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!