Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send a message to all connected sockets whenever an event happens #1

Open
luqmaan opened this issue Feb 28, 2014 · 1 comment
Open

Comments

@luqmaan
Copy link
Collaborator

luqmaan commented Feb 28, 2014

Inside of the upvote function, we need to send these to all connected sockets:

  • did
  • vote count

This will real time update vote count.

@luqmaan
Copy link
Collaborator Author

luqmaan commented Feb 28, 2014

Current upvote function:

@mod.route('/updebate/<int:entries_did>')
def up_vote(entries_did):
    connection = g.db.session.connection()
    g.db.engine.execute(
        'update users_user set rating = rating + 1 where id in (select id from users_debates where users_debates.did ="{0}")'.format(entries_did))
    g.db.engine.execute(
        'update users_debates set rating = rating + 1 where did = "{0}"'.format(entries_did))
    # g.db.commit()
    return redirect(request.referrer)

Make it so:

@mod.route('/updebate/<int:entries_did>')
def up_vote(entries_did):
    connection = g.db.session.connection()
    g.db.engine.execute(
        'update users_user set rating = rating + 1 where id in (select id from users_debates where users_debates.did ="{0}")'.format(entries_did))
    g.db.engine.execute(
        'update users_debates set rating = rating + 1 where did = "{0}"'.format(entries_did))
    socket.send("AEEFIOEF")
    return redirect(request.referrer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant