<commit_before>const express       = require('express');
const cors          = require('cors');
const http          = require('http');
const app           = express();

app.use(cors());

const server        = require('http').createServer(app);
const io            = require('socket.io')(server);
const uuid          = require('node-uuid');
const config        = require('./config');
const cookieParser  = require('cookie-parser');

app.use(cookieParser());

io.origins('*:*');

app.use(express.static(`build`));

let partyButtonCount = 51;

app.get('/assets/:id', (req,res) => {
  res.sendFile(__dirname + `/assets/` + req.params.id);
});

app.get('/party', (req, res) => {
  if (partyButtonCount > 50) {
    res.status(200).send();
  } else {
    res.status(404).send();
  }
});

app.get('*', (req, res) => {
  res.sendFile(__dirname + `/build/index.html`);
});

let PORT = process.env.PORT || config.PORT;
server.listen(PORT);
console.log(`Server listening on port: ${PORT}`);

let userCount = 0;
let usernames = {};           // username = { id: username }
let votes = {};               // votes = { songId: [userId, userId, userId] }
let upNext = [];
let playlist = [];
let lastUpNextList = [];

newUpNext = () => {
  // store songs that were just voted on and clear votes
  for (let songId in votes) {
    lastUpNextList = [];
    lastUpNextList.push(songId);
  };
  votes = {};
  let newSongs = {};
  if (playlist.length > 2) {
    let i = 0;
    while (i < 3) {
      let randomSong = playlist[Math.floor(Math.random() * playlist.length)];
      debugger;
      if (newSongs.hasOwnProperty(randomSong.songId) === false && lastUpNextList.indexOf(randomSong.songId) === -1) {
        newSongs[randomSong.songId] = randomSong;
        i++;
      };
    };
    upNext = [];
    for (let song in newSongs) {
      upNext.push(newSongs[song]);
      votes[song] = [];
    };
    console.log('Broadcasting new upNext list');
    io.emit('updateUpNext', { data: upNext });
  };
};
<commit_msg>fixed last voted on songs not being allowed to be voted on next<commit_after>const express       = require('express');
const cors          = require('cors');
const http          = require('http');
const app           = express();

app.use(cors());

const server        = require('http').createServer(app);
const io            = require('socket.io')(server);
const uuid          = require('node-uuid');
const config        = require('./config');
const cookieParser  = require('cookie-parser');

app.use(cookieParser());

io.origins('*:*');

app.use(express.static(`build`));

let partyButtonCount = 51;

app.get('/assets/:id', (req,res) => {
  res.sendFile(__dirname + `/assets/` + req.params.id);
});

app.get('/party', (req, res) => {
  if (partyButtonCount > 50) {
    res.status(200).send();
  } else {
    res.status(404).send();
  }
});

app.get('*', (req, res) => {
  res.sendFile(__dirname + `/build/index.html`);
});

let PORT = process.env.PORT || config.PORT;
server.listen(PORT);
console.log(`Server listening on port: ${PORT}`);

let userCount = 0;
let usernames = {};           // username = { id: username }
let votes = {};               // votes = { songId: [userId, userId, userId] }
let upNext = [];
let playlist = [];
let lastUpNextList = [];

newUpNext = () => {
  // store songs that were just voted on and clear votes
  lastUpNextList = [];
  for (let songId in votes) {
    lastUpNextList.push(songId);
  };
  votes = {};
  let newSongs = {};
  if (playlist.length > 2) {
    let i = 0;
    while (i < 3) {
      let randomSong = playlist[Math.floor(Math.random() * playlist.length)];
      debugger;
      if (newSongs.hasOwnProperty(randomSong.songId) === false && lastUpNextList.indexOf(randomSong.songId) === -1) {
        newSongs[randomSong.songId] = randomSong;
        i++;
      };
    };
    upNext = [];
    for (let song in newSongs) {
      upNext.push(newSongs[song]);
      votes[song] = [];
    };
    console.log('Broadcasting new upNext list');
    io.emit('updateUpNext', { data: upNext });
  };
};

{'fraction_non_alphanumeric': 0.18452380952380953, 'fraction_numerical': 0.00744047619047619, 'mean_word_length': 2.904162633107454, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '553134', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1324, 'n_words': 296}