async function getProgressList()

in src/LangList.js [35:79]


async function getProgressList(langs) {
  // TODO this search requires looking for issues with the string "Translation Progress"
  // in the title. Maybe we should replace it with something more robust.
  const { search } = await graphql(
    `
      query($limit: Int!) {
        search(
          type: ISSUE
          query: "org:reactjs Translation Progress in:title"
          first: $limit
        ) {
          nodes {
            ... on Issue {
              title
              body
              createdAt
              lastEditedAt
              number
              repository {
                name
              }
            }
          }
        }
      }
    `,
    {
      headers: {
        authorization: `token ${process.env.REACT_APP_GITHUB_AUTH_TOKEN}`,
      },
      limit: langs.length + 5, // padding in case of extra issues
    },
  )
  console.log(search.nodes)
  const issuesMap = fromPairs(
    search.nodes
      .filter(issue => !!issue && issue.repository)
      .map(issue => [issue.repository.name, issue]),
  )

  return langs.map(lang => {
    const issue = issuesMap[`${lang.code}.reactjs.org`]
    return issue ? getLangProgress(lang, issue) : null
  }).filter(Boolean)
}