Skip to content

Commit

Permalink
WIP - pandas
Browse files Browse the repository at this point in the history
  • Loading branch information
Signorini committed Nov 29, 2018
1 parent 1006579 commit d90e2e6
Show file tree
Hide file tree
Showing 17 changed files with 216,196 additions and 42 deletions.
1,487 changes: 1,487 additions & 0 deletions 5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6

Large diffs are not rendered by default.

1,487 changes: 1,487 additions & 0 deletions 5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.1

Large diffs are not rendered by default.

41,140 changes: 41,140 additions & 0 deletions 5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.10

Large diffs are not rendered by default.

41,140 changes: 41,140 additions & 0 deletions 5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.11

Large diffs are not rendered by default.

1,487 changes: 1,487 additions & 0 deletions 5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.2

Large diffs are not rendered by default.

1,487 changes: 1,487 additions & 0 deletions 5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.3

Large diffs are not rendered by default.

1,487 changes: 1,487 additions & 0 deletions 5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.4

Large diffs are not rendered by default.

1,487 changes: 1,487 additions & 0 deletions 5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.5

Large diffs are not rendered by default.

1,487 changes: 1,487 additions & 0 deletions 5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.6

Large diffs are not rendered by default.

41,140 changes: 41,140 additions & 0 deletions 5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.7

Large diffs are not rendered by default.

41,140 changes: 41,140 additions & 0 deletions 5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.8

Large diffs are not rendered by default.

41,140 changes: 41,140 additions & 0 deletions 5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.9

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/controller/__init__.py
Expand Up @@ -5,3 +5,4 @@

from .reports import ReportsApp
from .reportSingle import ReportSingleApp
from .reportsAggregation import ReportAggregationApp
77 changes: 39 additions & 38 deletions app/controller/general.py
Expand Up @@ -9,47 +9,48 @@


class GeneralReport(Resource):
def post(self):
"""
@api {post} /reports/general/ Create general graph
@apiName PostGeneral
@apiGroup Reports
"""
@api {post} /reports/general/ Create general graph
@apiName PostGeneral
@apiGroup Reports
@apiParam(Param) {String} report_id Report ID, created by server app
@apiParam(Param) {String} component Main Component [servers, applications, volumes, network, systems, clients, datacenters]
@apiParam(Param) {String} owner_user User/Team Id [uuid]
@apiParam(Param) {Json} filters List of filters.
<br/>
<pre class="prettyprint language-json" data-type="json">
<code>[{
<br/> field: "(String)",
<br/> filter: "(String value)",
<br/> comparer: "(Equal type)", //equal, contain, not contain
<br/> typ: "(Field Type)" //boolean, string, date
<br/>}]
</code>
</pre>
<br/>
<pre class="prettyprint language-json" data-type="json">
<code>[{
<br/> field: "active",
<br/> filter: "true",
<br/> comparer: "equal",
<br/> typ: "boolean"
<br/>}]
</code>
</pre>
@apiParam(Param) {String} report_id Report ID, created by server app
@apiParam(Param) {String} component Main Component [servers, applications, volumes, network, systems, clients, datacenters]
@apiParam(Param) {String} owner_user User/Team Id [uuid]
@apiParam(Param) {Json} filters List of filters.
<br/>
<pre class="prettyprint language-json" data-type="json">
<code>[{
<br/> field: "(String)",
<br/> filter: "(String value)",
<br/> comparer: "(Equal type)", //equal, contain, not contain
<br/> typ: "(Field Type)" //boolean, string, date
<br/>}]
</code>
</pre>
<br/>
<pre class="prettyprint language-json" data-type="json">
<code>[{
<br/> field: "active",
<br/> filter: "true",
<br/> comparer: "equal",
<br/> typ: "boolean"
<br/>}]
</code>
</pre>
@apiError (Error) BadRequest Missing parameters
@apiError (Error) NotFound List is empty
@apiError (Error) BadRequest Missing parameters
@apiError (Error) NotFound List is empty
@apiSuccessExample {json} Success-Response:
HTTP/1.1 200 OK
{
'filter': {List of filters},
'general-id': (Report ID)
}
"""
@apiSuccessExample {json} Success-Response:
HTTP/1.1 200 OK
{
'filter': {List of filters},
'general-id': (Report ID)
}
"""

def post(self):
valid = Validate().validate()

if valid:
Expand Down
10 changes: 7 additions & 3 deletions app/controller/reportSingle.py
Expand Up @@ -13,7 +13,7 @@
class ReportSingleApp(Resource):
def get(self, table_name):
"""
@api {post} /reports/<table_name>/ Get Table Data
@api {get} /reports/<table_name>/ Get Table Data
@apiName GetTableData
@apiGroup Reports
Expand All @@ -22,7 +22,11 @@ def get(self, table_name):
@apiSuccessExample {json} Success-Response:
HTTP/1.1 200 OK
[{
All data key: value
"limit": <int>,
"total_pages": <int>,
"found": <int>,
"page": <int>,
"items": []
}]
"""
Report = Reports(table_name)
Expand Down Expand Up @@ -55,7 +59,7 @@ def get(self, table_name):

def delete(self, table_name):
"""
@api {post} /reports/<table_name>/ Delete Table Data
@api {delete} /reports/<table_name>/ Delete Table Data
@apiName DeleteTableData
@apiGroup Reports
Expand Down
38 changes: 38 additions & 0 deletions app/controller/reportsAggregation.py
@@ -0,0 +1,38 @@
import pandas as pd
from flask import request
from flask_restful import Resource

from app.repository.reports import Reports


class ReportAggregationApp(Resource):

def get(self, table_name):
"""
@api {get} /aggregation/<table_name>/ Get Data Aggregation
@apiName GetTableAggregation
@apiGroup Reports
@apiParam(Param) {String} table_name Table Name
@apiSuccessExample {json} Success-Response:
HTTP/1.1 200 OK
[{
"name": <int>,
"aggr": []
}]
"""
Report = Reports(table_name)
data = Report.getAll(limit=99999)

df = pd.DataFrame(data)

datacenters = df['datacenters'].apply(pd.Series)


print(datacenters.groupby('name', as_index=False).agg({"_id": "count"}))



req = request.args.to_dict()
return data
3 changes: 2 additions & 1 deletion app/views.py
Expand Up @@ -8,7 +8,7 @@
from app import app
from flask import jsonify

from .controller import HomeApp, GeneralReport, PivotReport, ReportsApp, ReportSingleApp
from .controller import HomeApp, GeneralReport, PivotReport, ReportsApp, ReportSingleApp, ReportAggregationApp

api = Api(app)

Expand All @@ -17,6 +17,7 @@
api.add_resource(PivotReport, '/reports/pivot')
api.add_resource(ReportsApp, '/reports')
api.add_resource(ReportSingleApp, '/reports/<table_name>')
api.add_resource(ReportAggregationApp, '/aggregation/<table_name>')


@app.errorhandler(404)
Expand Down

0 comments on commit d90e2e6

Please sign in to comment.