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

Handle recipients in a list #60

Closed
bexelbie opened this issue Jun 14, 2018 · 1 comment
Closed

Handle recipients in a list #60

bexelbie opened this issue Jun 14, 2018 · 1 comment

Comments

@bexelbie
Copy link
Contributor

Some fedmsg messages, such as those from pagure return the list of actors/agents in a list. See this snippet from https://apps.fedoraproject.org/datagrepper/id?id=2018-824646b9-0bd1-4b10-a852-ec00dc6ccad7&is_raw=true&size=extra-large

{     
  "username": "git",
...   
  "msg": {
    "forced": false, 
... 
    "authors": [
      {
        "fullname": "Pierre-YvesChibon", 
        "name": "pingou"
      }, 
      {
        "fullname": "Lubom\u00edr Sedl\u00e1\u0159", 
        "name": "lsedlar"
      }
    ], 
    "total_commits": 2, 
    "start_commit": "da090b8449237e3878d4d1fe56f7f8fcfd13a248"
  }
}

Today we don't have a way to describe the path to the names in this kind of a situation.

I propose we add a second level processor that would know to parse the list.

I'd insert something like this into fedbadges/rules.py

self.recipient_list = self._d.get('recipient_list')
self.recipient_list_key = self._d.get('recipient_list_key')

if isinstance(obj, list) and self.recipient_list and self.recipient_list_key:
    awardees=[item[self.recipient_list_key] for item in obj]
else:
    awardees = obj

I know this needs a test to see if the key exists. I am not sure of the python idiomatically correct to write it.

Any comments?

This would allow us to begin awarding the pagure and docs badges.

@jwflory
Copy link
Member

jwflory commented Jun 26, 2018

Since @ralphbean has the most experience with this code base as the primary author, his POV is probably most valuable. It sounds good to me, but I'm probably not the best person to ask. I'd love to solve the broken Pagure and docs beat-writing badges.

sayanchowdhury pushed a commit that referenced this issue Mar 1, 2019
Pagure sends the authors of a commit in a list of dictionnary. This commit
supports this case by extracting the name from the dictionnary.

Fixes #60

Signed-off-by: Clement Verna <cverna@tutanota.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants