pacexy/poro

Issue or Bug Joining PicksAndBans

Closed this issue · 5 comments

I can't tell if it's something I'm doing wrong or if it is a bug, but when I added PicksAndBansS7 to an existing query, the fields on that table do not get added to the response. What's weird is the URL poro generates works as expected when I visit it in a web browser, but the response from the library doesn't include any PicksAndBansS7 fields.

Implementation:

const response = await getLeaguepediaMatchGamesByDateRange('2022-04-04','2022-04-24');

export const getLeaguepediaMatchGamesByDateRange = async (startDate: string, endDate: string) => {
  const results = await cargo.query({
    tables: ['ScoreboardGames', 'Tournaments', 'Leagues', 'MatchScheduleGame', 'MatchSchedule', 'PicksAndBansS7'],
    joinOn: [
      {
        left: 'Tournaments.League',
        right: 'Leagues.League'
      },
      {
        left: 'ScoreboardGames.OverviewPage',
        right: 'Tournaments.OverviewPage'
      },
      {
        left: 'ScoreboardGames.GameId',
        right: 'MatchScheduleGame.GameId'
      },

      {
        left: 'MatchScheduleGame.MatchId',
        right: 'MatchSchedule.MatchId'
      },
      {
        left: 'ScoreboardGames.GameId',
        right: 'PicksAndBansS7.GameId'
      }
    ],
    fields: [
      'MatchScheduleGame.OverviewPage',
      'ScoreboardGames.GameId',
      'ScoreboardGames.Team1',
      'ScoreboardGames.Team2',
      'ScoreboardGames.Winner',
      'ScoreboardGames.N_GameInMatch',
      'ScoreboardGames.Gamelength',
      'ScoreboardGames.Patch',
      'ScoreboardGames.RiotPlatformGameId',
      'MatchSchedule.DateTime_UTC',
      'PicksAndBansS7.Team1Role1', // Not in response
    ],
    where: `Leagues.League_Short = 'LPL' AND MatchSchedule.DateTime_UTC >= '${startDate}' AND MatchSchedule.DateTime_UTC <= '${endDate}'`
  });
  if (!results || results.status !== 200) {
    throw new Error('Failed to run query.');
  }
  return results.data;
};

Response example:

[
        {
            "OverviewPage": "LPL/2022 Season/Spring Playoffs",
            "GameId": "LPL/2022 Season/Spring Playoffs_Round 4_1_2",
            "Team1": "Top Esports",
            "Team2": "Victory Five",
            "Winner": 2,
            "N_GameInMatch": 2,
            "Gamelength": "32:35",
            "Patch": "12.5",
            "RiotPlatformGameId": null,
            "DateTime_UTC": "2022-04-12T09:00:00.000Z"
        },
        ...
 ]

Resulting Search URL:

https://lol.fandom.com/wiki/Special:CargoExport?tables=ScoreboardGames,Tournaments,Leagues,MatchScheduleGame,MatchSchedule,PicksAndBansS7&fields=MatchScheduleGame.OverviewPage,ScoreboardGames.GameId,ScoreboardGames.Team1,ScoreboardGames.Team2,ScoreboardGames.Winner,ScoreboardGames.N_GameInMatch,ScoreboardGames.Gamelength,ScoreboardGames.Patch,ScoreboardGames.RiotPlatformGameId,MatchSchedule.DateTime_UTC,PicksAndBansS7.Team1Role1&where=Leagues.League_Short+=+%27LPL%27+AND+MatchSchedule.DateTime_UTC+%3E=+%272022-04-04%27+AND+MatchSchedule.DateTime_UTC+%3C=+%272022-04-24%27&join+on=Tournaments.League=Leagues.League,ScoreboardGames.OverviewPage=Tournaments.OverviewPage,ScoreboardGames.GameId=MatchScheduleGame.GameId,MatchScheduleGame.MatchId=MatchSchedule.MatchId,ScoreboardGames.GameId=PicksAndBansS7.GameId&order+by=ScoreboardGames._pageName&limit=9007199254740991&offset=0&format=json

Resulting Search URL Example:

    {
        "OverviewPage": "LPL\/2022 Season\/Spring Playoffs",
        "GameId": "LPL\/2022 Season\/Spring Playoffs_Round 4_1_2",
        "Team1": "Top Esports",
        "Team2": "Victory Five",
        "Winner": 2,
        "N GameInMatch": 2,
        "Gamelength": "32:35",
        "Patch": 12.5,
        "RiotPlatformGameId": "",
        "DateTime UTC": "2022-04-12 09:00:00",
        "Team1Role1": "Bot",
        "DateTime UTC__precision": 0
    },

I have a feeling I'm doing something wrong, but I haven't been able to get anything working. Help or suggestions would be greatly appreciated, thanks!

Facing the same issue, Did you find any solution?

@MahmoudAFarag No. If you log the error you can grab the generated URL from the object and query that, assuming it works though. You lose autogenerated types, but you can always make a static interface if it's important.

Sorry to reply so late. I will figure it out.

Try v2.1.3

Try v2.1.3

Confirming that this fixed the issue. Thank you!