@@ -2,6 +2,7 @@ var sleep = require('sleep'); |
2 | 2 | const sequelize = require("sequelize"); |
3 | 3 | var authController = require('../controllers/authcontroller.js'); |
4 | 4 | var models = require("../models"); |
| 5 | +const Op = sequelize.Op; |
5 | 6 |
|
6 | 7 | var appRouter = function (app, passport) { |
7 | 8 | app.get("/", function (req, res) { |
@@ -56,33 +57,33 @@ var appRouter = function (app, passport) { |
56 | 57 | models.question.update({ |
57 | 58 | result: 'yes' }, { where: { id: req.body.question_primary_id }} |
58 | 59 | ) |
59 | | - models.bet_primary.findAll({ where: { question_id: req.body.question_primary_id }}) |
60 | | - .then(bets => { |
61 | | - bets.forEach(bet => { |
62 | | - bet.update({settled: true }) |
63 | | - }) |
64 | | - }) |
| 60 | + models.bet_primary.update({ |
| 61 | + settled: 'yes'}, { where: {question_id: req.body.question_primary_id}} |
| 62 | + ) |
| 63 | + models.match.update({ |
| 64 | + settled: 'yes'}, { where: {question_id: req.body.question_primary_id}} |
| 65 | + ) |
65 | 66 |
|
66 | | - models.match.findAll({ where: { question_id: req.body.question_primary_id }}) |
67 | | - .then(bets => { |
68 | | - bets.forEach(bet => { |
69 | | - bet.update({settled: true }) |
70 | | - }) |
71 | | - }) |
72 | | - // console.log(models.user.findAll()) |
73 | | - // console.log("yooooooooooo") |
74 | | - models.bet_primary.findAll({ where: { question_id: req.body.question_primary_id}}) |
| 67 | + // models.match.findAll({ where: { question_id: req.body.question_primary_id}}) |
| 68 | + // .then(matches => { |
| 69 | + // matches.forEach(matche => { |
| 70 | + // models.user.findAll({ where: { id: matche.yes_user_id}}) |
| 71 | + // .then(users => { |
| 72 | + // console.log('USERS----------:\n', users) |
| 73 | + // users.forEach(yes_user => { |
| 74 | + // var prev_balance = yes_user.balance; |
| 75 | + // yes_user.update({ |
| 76 | + // balance: prev_balance + matche.amount * (float(matche.yes_odds_numerator) / float(matche.yes_odds_denominator)) |
| 77 | + // }); |
| 78 | + // }); |
| 79 | + // }); |
| 80 | + // }); |
| 81 | + // }); |
| 82 | + |
| 83 | + models.user.findAll({ where: { question_id: req.body.question_primary_id}}) |
75 | 84 | .then(bets => { |
76 | 85 | console.log(bets) |
77 | 86 | bets.forEach(bet => { |
78 | | - // console.log(bet.user_id) |
79 | | - // .then(use => { |
80 | | - // var use_balance = use.balance |
81 | | - // user.update({ |
82 | | - // balance: use_balance + (1 *int(bet.option === 'yes') - 1 * int(bet.option === 'no')) * (float(bet.odds_numerator) / float(bet.odds_denominator)) * bet.amount |
83 | | - // }) |
84 | | - // }) |
85 | | - |
86 | 87 | bet.update({resolved: true }) |
87 | 88 | }) |
88 | 89 | }) |
@@ -254,7 +255,7 @@ var appRouter = function (app, passport) { |
254 | 255 | app.get('/signup', authController.signup); |
255 | 256 | app.get('/signin', authController.signin); |
256 | 257 | app.post('/signup', passport.authenticate('local-signup', { |
257 | | - successRedirect: '/rolou', |
| 258 | + successRedirect: '/questions', |
258 | 259 | failureRedirect: '/signup' |
259 | 260 | } |
260 | 261 | )); |
|
0 commit comments