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

[rocketchat] Add support for RocketChat #882

Closed
wants to merge 1 commit into from

Conversation

animeshk08
Copy link
Contributor

@animeshk08 animeshk08 commented May 26, 2020

This commit adds support for Pagure
to elk. Raw and enriched indexes have
been added.

Fixes: #876

Signed-off-by: Animesh Kumar [email protected]

This commit adds support for Pagure
to elk. Raw and enriched indexes have
been added.

Signed-off-by: Animesh Kumar <[email protected]>
@animeshk08
Copy link
Contributor Author

animeshk08 commented May 26, 2020

Hi, @valeriocos I sincerely apologize for the delay with this work. I was really occupied for the past few weeks.

I tried to include all the important field coming from the backend, let me know if anything is missed. I will include the remaining files and tests once we finalize on the enricher.

Again, I apologize and thank you for your patience.

\cc @vchrombie

EDIT: The format to pass to Mordred is same as mentioned here: chaoss/grimoirelab-perceval#661 (review) and the testing can be done on these channels,https://open.rocket.chat/channel/sandbox and https://open.rocket.chat/channel/general or a custom channel(suggested)
EDIT2: Tests are failing as Perceval backend is not merged

@coveralls
Copy link

coveralls commented May 27, 2020

Pull Request Test Coverage Report for Build 2210

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 36 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.7%) to 81.246%

Files with Coverage Reduction New Missed Lines %
/home/travis/build/chaoss/grimoirelab-elk/grimoire_elk/utils.py 36 65.78%
Totals Coverage Status
Change from base Build 2208: -0.7%
Covered Lines: 8140
Relevant Lines: 10019

💛 - Coveralls

@valeriocos valeriocos self-requested a review May 27, 2020 16:39
Copy link
Member

@valeriocos valeriocos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @animeshk08 , sorry for the late reply! Lately I don't have too much time to dedicate to community issues/pull requests, so I do it when I get some time.

The PR looks great, I tested it on the whole "https://open.rocket.chat general" and the execution was successful. I left some comments.

Based on the implementation you proposed, can you list some metrics you would like to show in the dashboard? Do you think we can be close to the metrics for other messaging systems (e.g., slack, mattermost)?

eitem['file_name'] = message['file'].get('name', None)
eitem['file_type'] = message['file'].get('type', None)

if 'replies' in message and message['replies']:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field seems to be always empty. Do you have an example?
Does it make sense to store only the number of replies?

self.add_metadata_filter_raw(eitem)
return eitem

def __get_reactions(self, item):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation generates a mapping for any reaction type (https://gist.github.com/valeriocos/9b103650bc24df8185aecb8f5df3a43f#file-rocketchat-mapping-L156), this may be a problem when trying to summing up reactions of different types.

I would suggest to:

  • add a metric that shows the total number of reactions for a given message
  • modify the code to have a single mapping for reactions, which contains a list of names, usernames, the type of the reaction and the count of reactions for that type (basically the lenght of the list of names/usernames)
"reaction" : {
            "properties" : {
              "names" : {
                "type" : "keyword"
              },
              "usernames" : {
                "type" : "keyword"
              },
               "count" : {
                "type" : "long"
              },
               "type" : {
                "type" : "keyword"
              }
            }
          },

WDYT?

return reactions

def __get_mentions(self, mentioned):
"""Enrich users mentioned in the message"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would complete this method with the total number of mentions, it may be useful to calculate some global metrics (e.g., number of mentions in different channels), wdyt?

'channel_name': channel['name'],
'channel_num_users': channel['usersCount'],
}
if 'lastMessage' in channel and channel['lastMessage']:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we store the lastMessage info?

rich_urls = []
for url in urls:
rich_url = {}
if 'meta' in url:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we want to store also the meta info? Is the URL not enough?

eitem['user_name'] = author.get('name', None)
eitem['user_username'] = author.get('username', None)

if 'editedBy' in message and message['editedBy']:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be useful to add an attribute that says whether the message has been edited or not (e.g., is_edited = 0/1). This can be useful to count the number of edited messages

if self.prjs_map:
eitem.update(self.get_item_project(eitem))

self.add_repository_labels(eitem)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The grimoire_creation_date isn't present in the enriched_items, you should add a statement similar to: https://github.com/chaoss/grimoirelab-elk/blob/master/grimoire_elk/enriched/mattermost.py#L193

@lukaszgryglicki
Copy link
Contributor

lukaszgryglicki commented Jun 9, 2020

This PR is not working yet, see p2o.py --enrich --index test-rc-raw --index-enrich test-rc -e [redacted] --bulk-size 50 --scroll-size 50 --db-host [redacted] --db-sortinghat sortinghat --db-user sortinghat --db-password [redacted] rocketchat -t [redacted] -u [redacted] --from-date '2020-06-04' https://chat.hyperledger.org general:

Traceback (most recent call last):
  File "/repos/grimoirelab-elk/grimoire_elk/elk.py", line 530, in enrich_backend
    enrich_count = enrich_items(ocean_backend, enrich_backend)
  File "/repos/grimoirelab-elk/grimoire_elk/elk.py", line 318, in enrich_items
    total = enrich_backend.enrich_items(ocean_backend)
  File "/repos/grimoirelab-elk/grimoire_elk/enriched/enrich.py", line 389, in enrich_items
    rich_item = self.get_rich_item(item)
  File "/repos/grimoirelab-elk/grimoire_elk/enriched/enrich.py", line 93, in decorator
    eitem = func(self, *args, **kwargs)
  File "/repos/grimoirelab-elk/grimoire_elk/enriched/rocketchat.py", line 133, in get_rich_item
    eitem['mentions'] = self.__get_mentions(message['mentions'])
  File "/repos/grimoirelab-elk/grimoire_elk/enriched/rocketchat.py", line 170, in __get_mentions
    'name': usr['name']})
KeyError: 'name'

This fixes the problem vim /repos/grimoirelab-elk/grimoire_elk/enriched/rocketchat.py:

         for usr in mentioned:
-            if '_id' in usr.keys():
+            if '_id' in usr.keys() and 'name' in usr.keys():

obaroikoh added a commit to obaroikoh/grimoirelab-elk that referenced this pull request Jun 10, 2020
@valeriocos
Copy link
Member

@animeshk08 do you have time to finish this PR or @obaroikoh can take over?

@animeshk08
Copy link
Contributor Author

Hi @valeriocos I am a bit occupied for the coming weeks. Thank you for the patch @obaroikoh you can take over this PR.

@valeriocos
Copy link
Member

Thank you for the quick reply @animeshk08

obaroikoh added a commit to obaroikoh/grimoirelab-elk that referenced this pull request Jun 11, 2020
obaroikoh added a commit to obaroikoh/grimoirelab-elk that referenced this pull request Jun 11, 2020
obaroikoh added a commit to obaroikoh/grimoirelab-elk that referenced this pull request Jun 12, 2020
obaroikoh added a commit to obaroikoh/grimoirelab-elk that referenced this pull request Jun 12, 2020
obaroikoh added a commit to obaroikoh/grimoirelab-elk that referenced this pull request Jun 12, 2020
obaroikoh added a commit to obaroikoh/grimoirelab-elk that referenced this pull request Jun 12, 2020
obaroikoh added a commit to obaroikoh/grimoirelab-elk that referenced this pull request Jun 12, 2020
obaroikoh added a commit to obaroikoh/grimoirelab-elk that referenced this pull request Jun 13, 2020
obaroikoh added a commit to obaroikoh/grimoirelab-elk that referenced this pull request Jun 17, 2020
obaroikoh added a commit to obaroikoh/grimoirelab-elk that referenced this pull request Jun 18, 2020
valeriocos pushed a commit to valeriocos/GrimoireELK that referenced this pull request Jun 18, 2020
valeriocos pushed a commit that referenced this pull request Jun 19, 2020
@valeriocos valeriocos closed this Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Rocket.Chat] Add rocketchat backend support to ELK
4 participants