Обновление данных определенных строк в MySQL с использованием нескольких обещаний, только несколько обновляется, как сделать все это обновить? - PullRequest
0 голосов
/ 21 декабря 2018

Когда я нажимаю кнопку, он должен обновить строки в таблице MySQL, но это только пара из них , возможно, по какой-то причине отклоняя выборки, не знаю почему, в моем журнале консоли я получаюошибки.Я перебираю свой массив данных и использую Promise.all для извлечения и обновления строк.Буду признателен за любую помощь, я довольно долго застрял в этой проблеме.

     const previousMonthcompanyInfos = this.state.addDataOnce == 'true' && this.state.airlinesPreviousMonth &&  this.state.airlinesPreviousMonth.filter(t=> t.airlineName != 'Generic').map((airline, idx) => {
        Promise.all([
        fetch(`http://ca-fpscfb2:4000/totalOpenBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/totalOpenEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/totalOpenQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/P1OpenedPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/P2OpenedPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/ticketsThisCyclePreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/ticketsOneToThreeMonthsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/ticketsThreeToSixMonthsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/ticketsSixToTwelveMonthsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/ticketsMoreThanOneYearPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/1stMonthOpenedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/2ndMonthOpenedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/3rdMonthOpenedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/4thMonthOpenedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/1stMonthOpenedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/2ndMonthOpenedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/3rdMonthOpenedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/4thMonthOpenedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/1stMonthOpenedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/2ndMonthOpenedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/3rdMonthOpenedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/4thMonthOpenedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/1stMonthClosedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/2ndMonthClosedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/3rdMonthClosedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/4thMonthClosedEnhancementsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/1stMonthClosedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/2ndMonthClosedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/3rdMonthClosedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/4thMonthClosedBugsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/1stMonthClosedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/2ndMonthClosedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/3rdMonthClosedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/4thMonthClosedQuestionsPreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/LineValuePreviousMonth?airline=${airline.airlineName}&product=${airline.product}&M=${differenceBetweenCurrentMonthAndPreviousMonth}`),
        fetch(`http://ca-fpscfb2:4000/CRsDataPerAirlinePreviousMonth?airline=${airline.airlineName}&product=${airline.product}`),
        fetch(`http://ca-fpscfb2:4000/HLEsDataPerAirlinePreviousMonth?airline=${airline.airlineName}&product=${airline.product}`)
      ])
      .then(([totalBugs, totalEnhancements, totalQuestions, P1, P2, ticketCreationThisCycle, ticketCreationOneToThree,
              ticketsCreationThreeToSix, ticketsCreationSixToTwelve, ticketsCreationOneYear,
              monthOneOpenEnhancements, monthTwoOpenEnhancements, monthThreeOpenEnhancements, monthFourOpenEnhancements,
              monthOneOpenBugs, monthTwoOpenBugs, monthThreeOpenBugs, monthFourOpenBugs,
              monthOneOpenQuestions, monthTwoOpenQuestions, monthThreeOpenQuestions, monthFourOpenQuestions,
              monthOneClosedEnhancements, monthTwoClosedEnhancements, monthThreeClosedEnhancements, monthFourClosedEnhancements,
              monthOneClosedBugs, monthTwoClosedBugs, monthThreeClosedBugs, monthFourClosedBugs,
              monthOneClosedQuestions, monthTwoCloseQuestions, monthThreeClosedQuestions, monthFourClosedQuestions, lineValue, JSONCR, JSONHLE]) => Promise.all([totalBugs.json(), totalEnhancements.json(), totalQuestions.json(), P1.json(), P2.json(),
                                                                                                                                     ticketCreationThisCycle.json(), ticketCreationOneToThree.json(),ticketsCreationThreeToSix.json(), ticketsCreationSixToTwelve.json(), ticketsCreationOneYear.json(),
                                                                                                                                     monthOneOpenEnhancements.json(), monthTwoOpenEnhancements.json(), monthThreeOpenEnhancements.json(), monthFourOpenEnhancements.json(),
                                                                                                                                     monthOneOpenBugs.json(), monthTwoOpenBugs.json(), monthThreeOpenBugs.json(), monthFourOpenBugs.json(),
                                                                                                                                     monthOneOpenQuestions.json(), monthTwoOpenQuestions.json(), monthThreeOpenQuestions.json(), monthFourOpenQuestions.json(),
                                                                                                                                     monthOneClosedEnhancements.json(), monthTwoClosedEnhancements.json(), monthThreeClosedEnhancements.json(), monthFourClosedEnhancements.json(),
                                                                                                                                     monthOneClosedBugs.json(), monthTwoClosedBugs.json(), monthThreeClosedBugs.json(), monthFourClosedBugs.json(),
                                                                                                                                     monthOneClosedQuestions.json(), monthTwoCloseQuestions.json(), monthThreeClosedQuestions.json(), monthFourClosedQuestions.json(), lineValue.json(),
                                                                                                                                     JSONCR.json(), JSONHLE.json()
                                                                                                                                    ]).then(([totalBugs, totalEnhancements, totalQuestions, P1, P2, ticketCreationThisCycle, ticketCreationOneToThree,
              ticketsCreationThreeToSix, ticketsCreationSixToTwelve, ticketsCreationOneYear,
              monthOneOpenEnhancements, monthTwoOpenEnhancements, monthThreeOpenEnhancements, monthFourOpenEnhancements,
              monthOneOpenBugs, monthTwoOpenBugs, monthThreeOpenBugs, monthFourOpenBugs,
              monthOneOpenQuestions, monthTwoOpenQuestions, monthThreeOpenQuestions, monthFourOpenQuestions,
              monthOneClosedEnhancements, monthTwoClosedEnhancements, monthThreeClosedEnhancements, monthFourClosedEnhancements,
              monthOneClosedBugs, monthTwoClosedBugs, monthThreeClosedBugs, monthFourClosedBugs,
              monthOneClosedQuestions, monthTwoCloseQuestions, monthThreeClosedQuestions, monthFourClosedQuestions, lineValue, JSONCR, JSONHLE
            ]) => { 
        this.setState({  addDataOnce: 'false' }, () => {
          fetch(`http://ca-fpscfb2:4000/SavePreviousMonthlyValuesForPreviousMonth?previous_dashboardID=${this.state.lastInsertedDashboardID-1}
                 &airlineID=${airline.airlineID}&totalBugs=${totalBugs.data.total}&totalQuestions=${totalQuestions.data.total}&totalEnhancements=${totalEnhancements.data.total}
                 &totalOpen=${totalBugs.data.total+totalQuestions.data.total+totalEnhancements.data.total}&P1=${P1.data.total}&P2=${P2.data.total}&ticketCreationThisCycle=${ticketCreationThisCycle.data.total}&
                 &ticketCreationOneToThree=${ticketCreationOneToThree.data.total}&ticketsCreationThreeToSix=${ticketsCreationThreeToSix.data.total}&ticketsCreationSixToTwelve=${ticketsCreationSixToTwelve.data.total}
                 &ticketsCreationOneYear=${ticketsCreationOneYear.data.total}&monthOneOpenEnhancements=${monthOneOpenEnhancements.data.total}&monthTwoOpenEnhancements=${monthTwoOpenEnhancements.data.total}
                 &monthThreeOpenEnhancements=${monthThreeOpenEnhancements.data.total}&monthFourOpenEnhancements=${monthFourOpenEnhancements.data.total}&monthOneOpenBugs=${monthOneOpenBugs.data.total}&monthTwoOpenBugs=${monthTwoOpenBugs.data.total}
                 &monthThreeOpenBugs=${monthThreeOpenBugs.data.total}&monthFourOpenBugs=${monthFourOpenBugs.data.total}&monthOneOpenQuestions=${monthOneOpenQuestions.data.total}&monthTwoOpenQuestions=${monthTwoOpenQuestions.data.total}
                 &monthThreeOpenQuestions=${monthThreeOpenQuestions.data.total}&monthFourOpenQuestions=${monthFourOpenQuestions.data.total}&monthOneClosedEnhancements=${monthOneClosedEnhancements.data.total}&monthTwoClosedEnhancements=${monthTwoClosedEnhancements.data.total}
                 &monthThreeClosedEnhancements=${monthThreeClosedEnhancements.data.total}&monthFourClosedEnhancements=${monthFourClosedEnhancements.data.total}&monthOneClosedBugs=${monthOneClosedBugs.data.total}&monthTwoClosedBugs=${monthTwoClosedBugs.data.total}
                 &monthThreeClosedBugs=${monthThreeClosedBugs.data.total}&monthFourClosedBugs=${monthFourClosedBugs.data.total}&monthOneClosedQuestions=${monthOneClosedQuestions.data.total}&monthTwoCloseQuestions=${monthTwoCloseQuestions.data.total}
                 &monthThreeClosedQuestions=${monthThreeClosedQuestions.data.total}&monthFourClosedQuestions=${monthFourClosedQuestions.data.total}&monthOneLine=${lineValue.data.total + (monthOneOpenEnhancements.data.total + monthOneOpenBugs.data.total + monthOneOpenQuestions.data.total) - (monthOneClosedBugs.data.total + monthOneClosedEnhancements.data.total + monthOneClosedQuestions.data.total)}
                 &monthTwoLine=${lineValue.data.total + (monthOneOpenEnhancements.data.total + monthOneOpenBugs.data.total + monthOneOpenQuestions.data.total) - (monthOneClosedBugs.data.total + monthOneClosedEnhancements.data.total + monthOneClosedQuestions.data.total) 
                               + (monthTwoOpenBugs.data.total + monthTwoOpenEnhancements.data.total + monthTwoOpenQuestions.data.total) - (monthTwoCloseQuestions.data.total + monthTwoClosedBugs.data.total + monthTwoClosedEnhancements.data.total)}
                 &monthThreeLine=${lineValue.data.total + (monthOneOpenEnhancements.data.total + monthOneOpenBugs.data.total + monthOneOpenQuestions.data.total) - (monthOneClosedBugs.data.total + monthOneClosedEnhancements.data.total + monthOneClosedQuestions.data.total) 
                                 + (monthTwoOpenBugs.data.total + monthTwoOpenEnhancements.data.total + monthTwoOpenQuestions.data.total) - (monthTwoCloseQuestions.data.total + monthTwoClosedBugs.data.total + monthTwoClosedEnhancements.data.total)
                                 + (monthThreeOpenBugs.data.total + monthThreeOpenEnhancements.data.total + monthThreeOpenQuestions.data.total) - (monthThreeClosedBugs.data.total + monthThreeClosedEnhancements.data.total + monthThreeClosedQuestions.data.total)}
                &monthFourLine=${lineValue.data.total + (monthOneOpenEnhancements.data.total + monthOneOpenBugs.data.total + monthOneOpenQuestions.data.total) - (monthOneClosedBugs.data.total + monthOneClosedEnhancements.data.total + monthOneClosedQuestions.data.total) 
                                 + (monthTwoOpenBugs.data.total + monthTwoOpenEnhancements.data.total + monthTwoOpenQuestions.data.total) - (monthTwoCloseQuestions.data.total + monthTwoClosedBugs.data.total + monthTwoClosedEnhancements.data.total)
                                 + (monthThreeOpenBugs.data.total + monthThreeOpenEnhancements.data.total + monthThreeOpenQuestions.data.total) - (monthThreeClosedBugs.data.total + monthThreeClosedEnhancements.data.total + monthThreeClosedQuestions.data.total)
                                 + (monthFourOpenBugs.data.total+ monthFourOpenEnhancements.data.total + monthFourOpenQuestions.data.total) - (monthFourClosedBugs.data.total + monthFourClosedEnhancements.data.total + monthFourClosedQuestions.data.total)}
                &openedLastCycle=${monthFourOpenBugs.data.total + monthFourOpenEnhancements.data.total+ monthFourOpenQuestions.data.total}
                &resolvedLastCycle=${monthFourClosedBugs.data.total + monthFourClosedEnhancements.data.total + monthFourClosedQuestions.data.total}&JSONCR=${Base64.encode(JSON.stringify(JSONCR.data))}&JSONHLE=${Base64.encode(JSON.stringify(JSONHLE.data))}
                 `)
        }

        )

      }))


      }
    )
...