Merry3750 / scorigami

This project is dedicated to tracking all scorigami throughout history and keeping the scorigami chart up to date at all times.
http://NFLScorigami.com
MIT License
54 stars 19 forks source link

Not an issue... #58

Closed JJSell1 closed 11 months ago

JJSell1 commented 11 months ago

But any way to get a total by team that has made a scorigami?

Merry3750 commented 11 months ago

There's no easy way to do it with the current functionality, but if you'd like to dig through the data, you can find it here: https://nflscorigami.com/copydb

JJSell1 commented 11 months ago

It wasn't really hard to do. Your data is in a nested array. I just had to clean that up. Here is a copy of my code if you want to see it. Just saves it now to a csv.

fetch('https://nflscorigami.com/data') .then( response => { if (response.status !== 200) { console.log('Looks like there was a problem. Status Code: ' + response.status); return; }

  // Examine the text in the response
  response.json().then(function (data) {
    //console.log(JSON.stringify(data));
    //console.log('data.lemght: ' + data.matrix.length)
    var masterArray = []
    data.matrix.forEach(function (ptsLose) {
      //console.log('items at index ' + data.matrix.indexOf(ptsLose) +

' - ptsLose.length ' + ptsLose.length) ptsLose.forEach(function (item) { if(item.count != 0){ masterArray.push(item) } }) //console.log('current masterarray.length after a batch of ptsLose items: ' + masterArray.length) })

    //console.log(masterArray.length)

    var allWinnerNames = masterArray.map(function (item) {
      return item.first_team_win
    })

    var allLoserNames = masterArray.map(function (item) {
      return item.first_team_lose
    })

    var allNames = allWinnerNames.concat(allLoserNames)

    var allUniqueNames = allNames.filter(filterUniques)

    //console.log(allUniqueNames.length)

    allUniqueNames.sort()

    let exportData = []
    exportData.push("Team,Total,Home Wins,Home Loses,Away Wins,Away

Loses")

    allUniqueNames.map(function(teamToLookUp){
      let total = masterArray.filter(function(item){return (item.

first_team_win == teamToLookUp || item.first_team_lose == teamToLookUp)}). length let homeWins = masterArray.filter(function(item){return (item. first_team_home == teamToLookUp && item.first_team_win == teamToLookUp)}). length let homeLoses = masterArray.filter(function(item){return (item. first_team_home == teamToLookUp && item.first_team_lose == teamToLookUp)}). length let awayWins = masterArray.filter(function(item){return (item. first_team_away == teamToLookUp && item.first_team_win == teamToLookUp)}). length let awayLoses = masterArray.filter(function(item){return (item. first_team_away == teamToLookUp && item.first_team_lose == teamToLookUp)}). length exportData.push(teamToLookUp + ',' + total + ',' + homeWins + ','

function filterUniques(item, itemIndex, srcArray) { return srcArray.indexOf(item) === itemIndex }

On Mon, Dec 4, 2023 at 2:47 PM Merry3750 @.***> wrote:

There's no easy way to do it with the current functionality, but if you'd like to dig through the data, you can find it here: https://nflscorigami.com/data

— Reply to this email directly, view it on GitHub https://github.com/Merry3750/scorigami/issues/58#issuecomment-1839363946, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ2DIN53VXYBYQVBBOSXMBLYHYSDXAVCNFSM6AAAAABAGHRTYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZZGM3DGOJUGY . You are receiving this because you authored the thread.Message ID: @.***>