Scoutopian [v0.1.1] - 3 New Features and Some Improvements

in #utopian-io6 years ago (edited)

scoutopian-header-image_v011.png

New Features

1- Detailed GitHub name check

A detailed algorithm which searches for the Utopian username on several GitHub pages was implemented. I think the best way to represent the whole process is the visualization. So you can browse to the image below to see how name searching process works.
github_name_check_scoutopian.png
The implementation of the above flow diagram can be found here

2- Checking whether PR merge date / Commit date is recent enough
  • [development category] Bug Fixes and New Features must be submitted via Pull Requests. The Pull Request must have been merged within the past 14 days.
  • [translation category] The Pull Request must have been merged within the past 14 days.

The calculation to find out the validity of a pull request requires two basic dates. One of them is the creation date of the contribution on Utopian and the other one is the merge date of the pull request. Difference between these two dates should be less than or equal to 14 days.

  • [development & translation categories] Updates on Own Projects can be committed directly, without a Pull Request. Commits must not be older than 14 days.

If Scoutopian cannot find any pull request link, it will search for a commit link on the body of the contribution. Creation date of the contribution and the commit date of the updates will be used to check the validity. Difference between them should be less than or equal to 14 days as the rule says.

Preview

GIF-scoutopian-trs-woPR-CMT-Name-wDownvote.gif

3- Detecting the language of a contribution

It wasn't necessary to contribute in English on Tutorials, Video Tutorials and Blog Posts categories before Utopian Rules Update #8. But after the last updates, all contributions from all categories on Utopian.io must be written in English.

  • Contents of the contributions (post content) must be in plain English and fully understandable.

Scoutopian also began checking whether the contribution meets this general rule.
Scoutopian uses detectlanguage.com API which offers 5000 requests and 1 Mb of data per day. Environment variable DETECT_LANG_KEY should be set to connect to the API

Relevant lines of code can be found here

Preview

GIF-scoutopian-tut-wolanguage.gif

Other Improvements

GitHub API Implementation

Scoutopian used to follow Github links (user profiles, project repositories, pull requests, commits etc..) which provided by the contribution to fetch all the required GitHub data and handle them via cheerio (npm package) to check whether GitHub repository and the contribution meet the rules.
I noticed that it's not the best solution and can cause some issues. So I decided to use GitHub REST API instead.
GitHub offers 60 requests per hour for its API usage without any authentication. Basic Authentication was used with a "personal access token" to authenticate to GitHub. It enhances the API rate-limit from 60 to 5000 per hour. This limit looks adequate for today's needs. In case of needing more requests, users can be authenticated via OAuth to enhance the rate-limit to "5000 requests/hour per user" from "5000 requests/hour for all users".
Environment variable GITHUB_PAT should be set to connect to the API

Escaping from Callback Hell

Callbacks were used to handle asynchronous functions in the first version of the Scoutopian. Because of so many rules needed to be checked, I noticed that the code would turn out a callback hell. A callback hell is roughly something like this:

checkRule1(function(err, res){
    checkRule2(function(err, res){
        checkRule3(function(err, res){
            checkRule4(function(err, res){
                checkRule5(function(err, res){
                    //welcome to the fifth floor of the callback hell :P
                })
            })
        })
    })
})

It's obvious that it's not going somewhere well. So I decided to change the way Scoutopian handles asynchronous functions and I switched to Promises which looks like this:

checkRule1()
  .then(checkRule2())
  .then(checkRule3())
  .then(checkRule4())
  .then(checkRule5())
  .catch((err) => { console.log(err) })


• You can check the introduction post here to get more information about Scoutopian and the features which already implemented.

Relevant Commits



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @codingdefined, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

The output of Scoutopian for this contribution:

GIF-scoutopian-dev-v011.gif

Hey @techrube I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.28
TRX 0.12
JST 0.033
BTC 67066.21
ETH 3093.89
USDT 1.00
SBD 3.75