Good day, Habrasoobschestvo!
In the process of implementing one of my projects (with blackjack and all the other social charms), I had to implement the
functionality of voting (like, like / dislike, rating, etc) users for some essences of the project's subject area.
Disclaimer: to my great regret, further there will be only discourses on the functions of some abstract external polling service and not a single line of code or useful links, but I need to get feedback from knowledgeable people.')
Searching for Google solutions, could not find anything suitable. Basically, solutions (plug-ins for various web frameworks) are reduced to adding additional fields to existing tables (or collection objects in the case of MongoDB), in which the number of likes / dislikes is written, and also who of the users has already voted. Such solutions have significant drawbacks, since, on the one hand, they do not have sufficient flexibility to easily modify voting algorithms (which is very important for a new project in the process of finding the right model), and on the other hand, they require modification of the existing code and, even worse, data storage, to add voting functionality.
At the same time, there are a significant number of services that provide opportunities to add comments to your site, such as
cackle.me ,
disqus.com , etc. Services are external to the project under development and allow you to add the ability to comment anything on your own with minimal effort. site (or in the application).
There was a logical question, why there are no similar services for adding polls to your site?
Functions Required for Voting Services
- external API
- data storage on the external service side
- the possibility of deferred unloading data by votes
- solution of the classic use / like options on the external service side
- vote (like) user for some object
- all votes (likes) for a given object
- all user voices (when, for which objects, how)
- when building a list of objects, get information on which of the objects the current user voted for and with which result
- when building a list of objects, get information about the number of likes / dislikes or the number of assessments for 1,2,3,4,5 stars for each of the objects
Thus, the main logic of processing likes or rating takes on external service. For example, he should check whether the user's likes for a given object is not repeated and not allow such a vote to be taken. At the same time, the business logic of who can vote for what can be implemented already on the side of their own project.
Of the additional features I would like to see:
- The ability to separately vote for certain aspects of objects (tags).
- Versioning of voting (convenient for split testing, for one group of users we allow likes and dislikes, and for the other only likes and observe the behavior of users on the service).
- Adding events to the message queue about new likes that you can subscribe to and postpone processing them (for rating recalculations in the background, for example).
Website integration with the service
I think there should be 2 ways - from the backend and from the frontend (web client or mobile client). Since it is possible not to keep information about voices on your side at all, you can make requests to create likes or to get the number of likes for objects directly from the client (identifying yourself with a token). Thus, the page will be collected from several sources. You can also collect information about votes on the backend and inject it into the resulting data before sending them to the client, making requests to the external API. It is even possible asynchronous, so that while waiting for a response, you can perform other data processing.
There should be plug-ins for popular languages (Ruby, PHP, JS) allowing using mixins or simply adding new modules to a project to easily add the ability to like / dislike or evaluate domain objects.
Benefits
- No unnecessary information about votes in existing data structures at the storage level.
- Minimum code to add the possibility of voting on your website or mobile application.
- The possibility of integration solely by the client.
- Removes some of the load from the backend servers.
- Multiple voting models at the same time (convenient mechanism for split tests).
Instead of conclusion
This is how the service of my dream vote should look like this. I would like to get answers, can someone advise something similar? Or did you need such a service, would it be useful to you?