Skip to content

Commit

Permalink
Add initial infrastructure to generate the reports
Browse files Browse the repository at this point in the history
- manuscripts2/metrics folder containing files for different metrics
- bin/manuscripts2 to generate report from new_functions
- manuscripts2/report.py to create the report using Report class
  • Loading branch information
aswanipranjal committed Jul 14, 2018
1 parent 6b25218 commit 49d04c1
Show file tree
Hide file tree
Showing 7 changed files with 395 additions and 2 deletions.
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, '.')

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):

return {
"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, '..')

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

0 comments on commit 49d04c1

Please sign in to comment.