-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the query for listing companies
- Loading branch information
Showing
4 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from flask import Response | ||
from flask.views import View | ||
from bson import json_util | ||
from mcp import mongo | ||
|
||
|
||
class CompanyNames(View): | ||
#@app.route("/<string:komuna>/monthly-summary") | ||
def dispatch_request(self, viti, komuna): | ||
json = mongo.db.procurements.aggregate([ | ||
{ | ||
"$match": { | ||
"viti": viti, | ||
"city": komuna | ||
} | ||
}, | ||
{ | ||
"$group": { | ||
'_id': { | ||
'kompania_emri': '$kompania.emri', | ||
"aktiviteti": "$aktiviteti", | ||
'muaji': { | ||
'$month': '$dataNenshkrimit' | ||
} | ||
}, | ||
"vlera": { | ||
"$sum": "$kontrata.vlera" | ||
}, | ||
"qmimi": { | ||
"$sum": "$kontrata.qmimi" | ||
}, | ||
"qmimiAneks": { | ||
"$sum": "$kontrata.qmimiAneks" | ||
} | ||
}, | ||
}, | ||
{ | ||
'$sort': { | ||
'muaji': -1 | ||
} | ||
}, | ||
{ | ||
"$project": { | ||
"_id": 0, | ||
"pershkrimi": "$_id.aktiviteti", | ||
"kompania": "$_id.kompania_emri", | ||
"vlera": "$vlera", | ||
"qmimi": "$qmimi", | ||
"qmimiAneks": "$qmimiAneks", | ||
} | ||
} | ||
]) | ||
|
||
#pergjigjen e kthyer dhe te konvertuar ne JSON ne baze te json_util.dumps() e ruajme ne resp | ||
resp = Response( | ||
response=json_util.dumps(json['result']), | ||
mimetype='application/json') | ||
|
||
#ne momentin kur hapim sh.: http://127.0.0.1:5000/treemap duhet te kthejme JSON, ne rastin tone resp. | ||
return resp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
# Create the flask app. | ||
app = create_app() | ||
|
||
# Run the app | ||
if __name__ == '__main__': | ||
|
||
|