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

Add initial infrastructure to generate a report using new functions and classes #73

Merged
merged 1 commit into from
Jul 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions bin/manuscripts2
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Script for producing Reports from data in ElasticSearch
#
# Copyright (C) 2018 CHAOSS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Authors:
# Pranjal Aswani <aswani.pranjal@gmail.com>
#

import sys
sys.path.insert(0, '.')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this?


from manuscripts2.report import Report

test_report = Report(data_dir="PERCEVAL_TESTS", data_sources=['git', 'github_issues', 'github_prs'])
test_report.get_activity_metrics()
Empty file.
69 changes: 69 additions & 0 deletions manuscripts2/metrics/git.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
#
# Copyright (C) 2018 CHAOSS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Author:
# Pranjal Aswani <aswani.pranjal@gmail.com>
#

import sys
sys.path.insert(0, '..')

from manuscripts2.new_functions import Query


class GitMetrics():

def __init__(self, index):

self.name = "git"
self.commits = Query(index)

def get_section_metrics(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you're going to need parameters here... Maybe you could start with some, just to make it clear how that would work? For example, a since parameter, which would make all metrics to be computed since that date.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes @jgbarah you are right, each class will need a start and end date to configure the range in which to search/query for data. Thanks for pointing it out!


return {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is very much JavaScript-like ;-) I'm not completely sure yet, but I think we could improve it. But for now, that's ok with me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am sorry, I don't get the reference here. What is JS like?

"overview": {
"activity_metrics": [self.commits.get_cardinality("hash").by_period()],
"author_metrics": [],
"bmi_metrics": [],
"time_to_close_metrics": [],
"projects_metrics": []
},
"com_channels": {
"activity_metrics": [],
"author_metrics": []
},
"project_activity": {
# TODO: Authors is not activity but we need two metrics here
"metrics": []
},
"project_community": {
"author_metrics": [],
"people_top_metrics": [],
"orgs_top_metrics": [],
},
"project_process": {
"bmi_metrics": [],
"time_to_close_metrics": [],
"time_to_close_title": "",
"time_to_close_review_metrics": [],
"time_to_close_review_title": "",
"patchsets_metrics": []
}
}
71 changes: 71 additions & 0 deletions manuscripts2/metrics/github_issues.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
#
# Copyright (C) 2018 CHAOSS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Author:
# Pranjal Aswani <aswani.pranjal@gmail.com>
#

import sys
sys.path.insert(0, '..')
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above...


from manuscripts2.derived_classes import Issues


class IssuesMetrics():

def __init__(self, index):

self.name = "github_issues"
self.opened_issues = Issues(index)
self.closed_issues = Issues(index)
self.closed_issues.is_closed()

def get_section_metrics(self):

return {
"overview": {
"activity_metrics": [self.opened_issues.get_cardinality("id").by_period(),
self.closed_issues.get_cardinality("id").by_period()],
"author_metrics": [],
"bmi_metrics": [],
"time_to_close_metrics": [],
"projects_metrics": []
},
"com_channels": {
"activity_metrics": [],
"author_metrics": []
},
"project_activity": {
"metrics": []
},
"project_community": {
"author_metrics": [],
"people_top_metrics": [],
"orgs_top_metrics": [],
},
"project_process": {
"bmi_metrics": [],
"time_to_close_metrics": [],
"time_to_close_title": "Days to close (median and average)",
"time_to_close_review_metrics": [],
"time_to_close_review_title": "",
"patchsets_metrics": []
}
}
71 changes: 71 additions & 0 deletions manuscripts2/metrics/github_prs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
#
# Copyright (C) 2018 CHAOSS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Author:
# Pranjal Aswani <aswani.pranjal@gmail.com>
#

import sys
sys.path.insert(0, '..')

from manuscripts2.derived_classes import PullRequests


class PullRequestsMetrics():

def __init__(self, index):

self.name = "github_prs"
self.opened_prs = PullRequests(index)
self.closed_prs = PullRequests(index)
self.closed_prs.is_closed()

def get_section_metrics(self):

return {
"overview": {
"activity_metrics": [self.opened_prs.get_cardinality("id").by_period(),
self.closed_prs.get_cardinality("id").by_period()],
"author_metrics": [],
"bmi_metrics": [],
"time_to_close_metrics": [],
"projects_metrics": []
},
"com_channels": {
"activity_metrics": [],
"author_metrics": []
},
"project_activity": {
"metrics": []
},
"project_community": {
"author_metrics": [],
"people_top_metrics": [],
"orgs_top_metrics": [],
},
"project_process": {
"bmi_metrics": [],
"time_to_close_metrics": [],
"time_to_close_title": "Days to close (median and average)",
"time_to_close_review_metrics": [],
"time_to_close_review_title": "Days to close review (median and average)",
"patchsets_metrics": []
}
}
4 changes: 2 additions & 2 deletions manuscripts2/new_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def __init__(self, index, esfilters={}, interval=None, offset=None):
:param interval: interval to use for timeseries data
:param offset: TODO: this is still to be implemented
"""

self.search = Search(using=index.es, index=index.index_name)
self.index = index
self.search = Search(using=self.index.es, index=self.index.index_name)
self.parent_agg_counter = 0
self.filters = {}
self.filters.update(esfilters)
Expand Down
Loading