casspoll's People
casspoll's Issues
Docker setup for more than one Cassandra cluster
Bot runtime
It would be nice to have that in separate function to spawn more than one bot in goroutines per program
Bot could do something like:
- get active polls
- randomly select some of them and vote for them
- store somewhere the ids of polls that bot voted in
- make some worker that will get the results (timers launching goroutines)
- just after the poll due time
- shortly after (5-10 seconds)
- check if these results match (overall result, number of votes/option)
- log it if not matched - based on logs we could get the number of reads with corrupted results / number of reads
- we could run some bots (4 nodes, 2 seeds), make partition for some time and check how it affects the results (some bots may be not aware of some polls created "on the other side" of partition)
get Votes by voterId
GetResults query that takes poll's dueTime into consideration
Let's figure out if we adjust schema to make
SELECT answerId, COUNT(*) FROM votes WHERE pollId = ? AND createdAt < ? GROUP BY answerId
work. With current schema it requires to add ALLOW FILTERING
, already tried changing order of createdAt
and answerId
as SK. Current workaround - getting current time and prevent from voting if current time is bigger than poll's due time
possible solutions:
Schema RFC
CREATE KEYSPACE IF NOT EXISTS casspoll
WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
USE casspoll;
CREATE TABLE IF NOT EXISTS Polls (
pollId uuid,
title text,
description text,
dueTime timestamp,
pollType int,
PRIMARY KEY (pollId)
);
CREATE TABLE IF NOT EXISTS Answers (
answerId uuid,
answer text,
pollId uuid,
PRIMARY KEY (pollId, answerId)
)
-- idea #1
-- "server" prevents from inserting due to exceeding the deadline
CREATE TABLE IF NOT EXISTS Votes (
pollId uuid,
answerId uuid,
votesNo counter,
PRIMARY KEY (pollId, answerId)
);
-- voting
-- now := time.Now().Unix()
SELECT dueTime FROM polls WHERE pollId = ?;
-- if now < dueTime {}
-- for answer := range selectedAnswers {
UPDATE Votes SET votesNo = votesNo + 1 WHERE pollId = ? AND answerId = ?
-- }
-- }
-- calculating votes
-- for answer := range answers {
SELECT votesNo FROM Votes WHERE pollId = ? AND answerId = ?
-- }
-- idea #2
CREATE TABLE IF NOT EXISTS Votes (
pollId uuid,
answerId uuid,
voterId uuid,
PRIMARY KEY (pollId, answerId)
);
-- voting
-- now := time.Now().Unix()
-- for answer := range selectedAnswers {
INSERT INTO Votes (voterId) VALUES (?) WHERE pollId = ? AND answerId = ? USING TIMESTAMP now;
-- }
-- calculating votes
-- for answer := range answers {
-- SELECT COUNT(*) FROM Votes WHERE pollId = ? AND answerId = ? AND writetime(voterId) < dueTime
-- }
SELECT COUNT(*) FROM Votes WHERE pollId = ? AND writetime(voterId) < dueTime GROUP BY answerId
-- other options
-- + Votes include text for answer, no need for Answers table
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.