def get(self, crawler_id):
        args = parser.parse_args()
        aggregation_type = args["aggregation_type"]
        output_type = args["output_type"]

        crawlerJob = mongodbConnection.get_db().crawlerJobs.find_one(
            {"_id": crawler_id})
        if crawlerJob["status"] != "finished":
            return "Crawler Job did not finish yet", 404

        if aggregation_type.lower() not in allowedAggregationTypes:
            return "Wrong aggregation type provided: " + aggregation_type, 400

        if aggregation_type.lower() == "all" and output_type == "csv":
            return "Time series not supported", 400

        aggregator = Aggregator(crawler_id, aggregation_type.lower(),
                                crawlerJob["feature_set"],
                                crawlerJob["resource_configs"])
        aggregator.aggregate()

        if output_type == "csv":
            return Response(aggregator.getCSVOfAggregated(),
                            mimetype='text/csv')
        elif output_type == "json":
            return aggregator.getRestructured()
        else:
            return aggregator.getAggregated()
    def test_all(self):
        with api.app.app_context():
            reference = os.path.join(self.referenceDir, "test_all.json")
            generated = os.path.join(self.generatedDir, "test_all.json")

            aggregator = Aggregator(self.aggregatorTestTable, "all",
                                    self.job_info_json["feature_set"],
                                    self.job_info_json["resource_configs"])
            aggregator.aggregate()

            ret = aggregator.getAggregated()

            # Write results to file for better comparison on error
            generated_file = open(generated, "w")
            generated_file.write(str(json.dumps(ret, indent=2)))
            generated_file.close()

            self.assertEqual(json.loads(open(generated, "r").read()),
                             json.loads(open(reference, "r").read()))
Exemplo n.º 3
0
    def get_guild_reports(self, guild):
        members = self.get_active_guild_members(guild)

        if members == None or len(members) == 0:
            return None

        region_roles = {
            "eu": utilities.get_role(guild.roles, "eu"),
            "na": utilities.get_role(guild.roles, "na")
        }

        aggregator = Aggregator(members, region_roles)
        match_reports = aggregator.get_match_reports()
        stream_reports = aggregator.get_stream_reports(self.config.STREAM_TIME_LIMIT)

        return {
            "match": match_reports,
            "stream": stream_reports
        }
    def test_latest_csv(self):
        with api.app.app_context():
            reference = os.path.join(self.referenceDir, "test_latest_csv.txt")
            generated = os.path.join(self.generatedDir, "test_latest_csv.txt")

            aggregator = Aggregator(self.aggregatorTestTable, "latest",
                                    self.job_info_json["feature_set"],
                                    self.job_info_json["resource_configs"])
            aggregator.aggregate()

            ret = aggregator.getCSVOfAggregated()

            # Write results to file for better comparison on error
            generated_file = open(generated, "w")
            generated_file.write(ret)
            generated_file.close()

            self.assertEqual(
                open(generated, "r").read(),
                open(reference, "r").read())
Exemplo n.º 5
0
async def stat(message, name, param2):
    if len(name) == 0:
        name = utilities.get_member_name(message.author)

    player = Aggregator.get_player_stats(name)

    if player == None:
        print("No player found")
        await message.channel.send('No player found')
    else:
        embed = Notifications.build_stats(player)
        await message.channel.send(embed=embed)