open-source-uom / myuom

The myUoM app is a project of the Open Software Team of Applied Informatics, University of Macedonia (https://opensource.uom.gr). It was designed to facilitate students' daily interactions with the university.
https://my.uom.gr
MIT License
24 stars 16 forks source link

filter out bots in contributors section #123

Open papsavas opened 2 months ago

papsavas commented 2 months ago

Description

Currently we're showcasing all github contributors including bots (i.e dependabot). We should filter them out

Implementation

GitHub API returns a payload of Contributors Array containing a type value

Filter payload accordingly keeping only users

Object Array Filtered Mapping

Following some generic strategies for filtering out object arrays:

// cleanest code, slowest
const contributors = data
.filter(contributor => contributor.type === "User")
.map(contributor =>  ({ name: contributor.login }))
//fastest code, ugliest
const contributors = data
.reduce((acc, curr)=> {
  if(curr.type === "User") 
    acc.push({ name: curr.login });
  return acc;
}, []);
//one liner, one iteration, faster than filter > map but slower than reduce
const contributors = data
.flatMap(contributor => contributor.type === "User" ? [{ name: contributor.login }] : [])
angshumanraj commented 4 weeks ago

is this issue open?