Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugins/starlists): add ignored and aliases for starlists.languages and some fix #1224

Merged
merged 6 commits into from
Sep 14, 2022

Conversation

TonyCrane
Copy link
Contributor

Implemented the feature in #1223.

Changes

  • one fix in plugins/starlists
    • the loop below will not be broken if the star list has only one page (which means it doesn't have .next_page selector). So I added an extra condition for checking whether break the loop.
      for (let i = 1; i <= (languages ? 100 : 1); i++) {
      console.debug(`metrics/compute/${login}/plugins > starlists > fetching page ${i}`)
      await page.goto(`${list.link}?page=${i}`)
      repositories.push(
      ...await page.evaluate(() =>
      [...document.querySelectorAll("#user-list-repositories > div:not(.paginate-container)")].map(element => ({
      name: element.querySelector("div:first-child")?.innerText.replace(" / ", "/") ?? "",
      description: element.querySelector(".py-1")?.innerText ?? "",
      language: {
      name: element.querySelector("[itemprop='programmingLanguage']")?.innerText ?? "",
      color: element.querySelector(".repo-language-color")?.style?.backgroundColor?.match(/\d+/g)?.map(x => Number(x).toString(16).padStart(2, "0")).join("") ?? null,
      },
      stargazers: Number(element.querySelector("[href$='/stargazers']")?.innerText.trim().replace(/[^\d]/g, "") ?? NaN),
      forks: Number(element.querySelector("[href$='/network/members']")?.innerText.trim().replace(/[^\d]/g, "") ?? NaN),
      }))
      ),
      )
      if (await page.evaluate(() => document.querySelector(".next_page.disabled"))) {
      console.debug(`metrics/compute/${login}/plugins > starlists > reached last page`)
      break
      }
      }
  • added the feature
    • just same as plugins/languages
    • and I also updated metadata.yml and README.md
  • one docs fix in plugins/languages
    • the example of plugins_languages_aliases is wrong (javascript:JS typescript:TS), the separator is a comma instead of whitespace. I fixed that and also added this example to README.md.

Test

I have tested the new feature locally using my account and my star lists. It works fine!

original:

starlists.languages=1
starlists.limit.repositories=0
starlists.only=Learning,Tools

before

with new feature:

starlists.languages=1
starlists.limit.repositories=0
starlists.only=Learning,Tools
starlists.languages.ignored=html
starlists.languages.aliases=javascript:JS,Jupyter Notebook:ipynb

after

You can see that html has disappeared and javascript -> JS Jupyter Notebook -> ipynb.

@lowlighter lowlighter merged commit 98bbeb4 into lowlighter:master Sep 14, 2022
@lowlighter
Copy link
Owner

Thanks a lot for these awesome options and for your detailed post 🎉 !

@github-actions github-actions bot locked and limited conversation to collaborators Sep 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants