Update Utopian.Rocks API wrapper for Node.js, New Features v0.1.6
Repository
https://github.com/gigatoride/node-utopian-rocks
Intro image source edited by gigatoride
New Features
- Replace old aliases like
utopian.getModerators
toutopian.stats.getModeratorsByDate
- Advanced statistics methods
- Moderator Checker
- New Endpoints
New method aliases
// Retrive moderators list
utopian.getModerators()
// Check if moderator username is valid
utopian.isModerator(param)
// Retrive all time moderators statistics
utopian.stats.getModerators(params)
// Retrive all time projects statistics
utopian.stats.getProjects(params)
// Retrive all time contributors statistics
utopian.stats.getContributors(params)
// Retrive all moderators by date
utopian.stats.getModeratorsByDate(param)
// Retrive all projects by date
utopian.stats.getProjectsByDate(param)
// Retrive all staff picks by date
utopian.stats.getStaffPicksByDate(param)
// Retrive all staff categories by date
utopian.stats.getCategoriesByDate(param)
// Retrive all tasks requests by date
utopian.stats.getTasksRequestsByDate(param)
Improve API Test
Test using jest in this commit I've improved the testing:
npm test
Results:
New Endpoints and Improve API
this commit I've made general improvements and removed old endpoints like in the switch statment and replaced it with:
let endpoints = {
stats: require('./lib/stats')
}; // JS object for API endpoints.
I've also added moderator checker isModerator()
as a new endpoint
endpoints.isModerator = (username) => axios.get(API_URL + '/moderators') // Requesting moderators endpoint
.then(function (response) {
return response.data.includes(username) // Returns true or false.
})
.catch(function (error) {
return error; // Returns an error of something wrong with response.
});
More statistics
In this commit I've created a file for stats that will be exported to api.js
For example I've created the following algorithm to count the total reviewed contribtuions by all moderators with descending order.
response.data.filter(body => {
// tests whether at least one moderator in the array passes the test implemented by the provided function.
if (moderators.some(obj => obj.moderator === body.moderator)) {
// returns the index of the first moderator in the array that satisfies the provided testing function. Otherwise -1 is returned.
let objIndex = moderators.findIndex(
obj => obj.moderator == body.moderator // If moderator already exist in the array of objects
);
moderators[objIndex].reviewed++; // Count reviewed contributions by moderator
} else
// If not exist push it into the array.
return moderator.push({
moderator: body.moderator, // Moderator username
reviewed: 1 // Number of reviewed contributions
});
});
return moderators.sort((a, b) => b.reviewed - a.reviewed); // Sort moderators descendingly by number of reviews.
I also created similar algorthim in utopian.stats.getContributors()
and utopian.stats.getProjects()
with different options, usage.
README.md
In this README.md commit is the current documention for usage, however, I'm currently preparing doc
directory that will has a more detailed usage for all method aliases.
Looks great. Also, it's always a pleasure to review projects having tests.
I believe, utopian.rocks will be deprecated once the new interface of Utopian is released. So, I wouldn't be giving so much investment in terms of the development of a utopian.rocks client. :)
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? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
The source code can be useful for the official API too once it released :)
Yeah, but it would be a totally different API specs and endpoints. And not sure about it yet, but it may not be that public.
Thank you for your review, @emrebeyler!
So far this week you've reviewed 1 contributions. Keep up the good work!
Congratulations @gigatoride! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Hi @gigatoride!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server
Congratulations @gigatoride! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word
STOP
Hey, @gigatoride!
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!