Example #1
0
 def getData(self):
     jsonOndeFoiRoubado = self.getJsonFromOndeFoiRoubado()
     jsonOndeTemTiro = self.getJsonFromOnteTemTiro()
     postgre = Postgres()
     postgre.open()
     postgre.insertOndeFoiRoubado(jsonOndeFoiRoubado)
     postgre.insertOndeTemTiro(jsonOndeTemTiro)
     postgre.close()
Example #2
0
def type():
    postgre = Postgres()
    postgre.open()
    results = postgre.getType()
    postgre.close()
    types = fromResultsToType(results)
    return Response(json.dumps(types), status=200, mimetype='application/json')
Example #3
0
def agregaPorTipo():
    postgre = Postgres()
    postgre.open()
    results = postgre.getViolenceGroupByType()
    postgre.close()
    types = fromResultsToNeighborhood(results)
    return Response(json.dumps(types), status=200, mimetype='application/json')
Example #4
0
def amount():
    postgre = Postgres()
    postgre.open()
    results = postgre.getAmountOfLost()
    postgre.close()
    return Response(json.dumps({'amount': str(results[0][0])}),
                    status=200,
                    mimetype='application/json')
Example #5
0
def neighborhood():
    postgre = Postgres()
    postgre.open()
    results = postgre.getViolenceGroupByNeighborhood()
    postgre.close()
    neighborhoods = fromResultsToNeighborhood(results)
    return Response(json.dumps(neighborhoods),
                    status=200,
                    mimetype='application/json')
Example #6
0
def list_type(type, quantidade):
    postgre = Postgres()
    postgre.open()
    results = postgre.getViolenceByType(type, quantidade)
    postgre.close()
    violences = fromResultsToJson(results)
    return Response(json.dumps(violences),
                    status=200,
                    mimetype='application/json')
Example #7
0
def list_all():
    postgre = Postgres()
    postgre.open()
    results = postgre.getVeolance(0)
    postgre.close()
    violences = fromResultsToJson(results)
    return Response(json.dumps(violences),
                    status=200,
                    mimetype='application/json')
Example #8
0
def run_ml_filtered(tipo):
    postgre = Postgres()
    postgre.open()
    results = postgre.getVeolanceFilterByType(3000, tipo)
    postgre.close()
    violences = fromResultsToJson(results)
    ml = MachineLearnning()
    result = ml.run(violences)
    return Response(json.dumps(result),
                    status=200,
                    mimetype='application/json')
Example #9
0
def run_kde_filtered(tipo):
    postgre = Postgres()
    postgre.open()
    results = postgre.getVeolanceFilterByType(1000, tipo)
    postgre.close()
    violences = fromResultsToJson(results)
    kde = KDE()
    result = kde.run(violences)
    return Response(json.dumps(result),
                    status=200,
                    mimetype='application/json')
Example #10
0
def gender():
    postgre = Postgres()
    postgre.open()
    results = postgre.getLostBySex()
    print(results)
    masc = results[0][1] / (results[0][1] + results[1][1])
    fem = results[1][1] / (results[0][1] + results[1][1])
    postgre.close()
    return Response(json.dumps({
        'masculino': masc,
        'feminino': fem
    }),
                    status=200,
                    mimetype='application/json')