def get_best_collaborator()

in libmozdata/BZInfo.py [0:0]


    def get_best_collaborator(self):
        """Get the 'best' collaborator

        A collaboration between A & B is when A reviews a patch of B (or reciprocally)
        in term of graph:
           - each node represents a reviewer or a writer (owner)
           - each edge represents a collaboration
        here we count the degree of each node and find out who's the best collaborator

        it could be interesting to weight each contribution according to its date
        someone who made 20 contribs recently is probably better than someone 50 contribs
        two years ago...

        Returns:
            (str): a collaborator
        """
        # TODO: use this graph to get other metrics (??)
        # TODO: We could weight a contrib with a gaussian which depends to the time
        collaborations = {}
        for info in self.get().values():
            if info["authorized"]:
                owner = info["owner"]
                if owner not in collaborations:
                    collaborations[owner] = 0
                reviewers = info["reviewers"]
                feedbacks = info["feedbacks"]
                collabs = set()
                if reviewers and owner in reviewers:
                    collabs |= reviewers[owner]
                if feedbacks and owner in feedbacks:
                    collabs |= feedbacks[owner]
                if collabs:
                    collaborations[owner] += len(collabs)
                    for person in collabs:
                        collaborations[person] = (
                            collaborations[person] + 1
                            if person in collaborations
                            else 1
                        )

        # maybe we should compute the percentage of collaborations just to give an idea

        return utils.get_best(collaborations)