diff --git a/docker-compose.yaml b/docker-compose.yaml index e692dd8..43cd0e1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,54 +1,54 @@ version: '3' services: - kafka: - container_name: kafka - image: bitnami/kafka:3.5.1-debian-11-r3 - environment: - - ALLOW_PLAINTEXT_LISTENER=yes - - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094 - - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,EXTERNAL:PLAINTEXT - - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://localhost:9094 - - KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=false - # volumes: - # - ./kafka:/bitnami/kafka:rw - ports: - - 9094:9094 - - 9092:9092 - healthcheck: - test: ["CMD", "kafka-topics.sh", "--list", "--bootstrap-server", "localhost:9092"] - interval: 30s - timeout: 10s - retries: 5 - networks: - - botdetector-network + # kafka: + # container_name: kafka + # image: bitnami/kafka:3.5.1-debian-11-r3 + # environment: + # - ALLOW_PLAINTEXT_LISTENER=yes + # - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094 + # - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,EXTERNAL:PLAINTEXT + # - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://localhost:9094 + # - KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=false + # # volumes: + # # - ./kafka:/bitnami/kafka:rw + # ports: + # - 9094:9094 + # - 9092:9092 + # healthcheck: + # test: ["CMD", "kafka-topics.sh", "--list", "--bootstrap-server", "localhost:9092"] + # interval: 30s + # timeout: 10s + # retries: 5 + # networks: + # - botdetector-network - kafdrop: - container_name: kafdrop - image: obsidiandynamics/kafdrop:latest - environment: - - KAFKA_BROKERCONNECT=kafka:9092 - - JVM_OPTS=-Xms32M -Xmx64M - - SERVER_SERVLET_CONTEXTPATH=/ - ports: - - 9000:9000 - restart: on-failure - networks: - - botdetector-network - depends_on: - kafka: - condition: service_healthy + # kafdrop: + # container_name: kafdrop + # image: obsidiandynamics/kafdrop:latest + # environment: + # - KAFKA_BROKERCONNECT=kafka:9092 + # - JVM_OPTS=-Xms32M -Xmx64M + # - SERVER_SERVLET_CONTEXTPATH=/ + # ports: + # - 9000:9000 + # restart: on-failure + # networks: + # - botdetector-network + # depends_on: + # kafka: + # condition: service_healthy - kafka_setup: - container_name: kafka_setup - build: - context: ./kafka_setup - environment: - - KAFKA_BROKER=kafka:9092 - networks: - - botdetector-network - depends_on: - kafka: - condition: service_healthy + # kafka_setup: + # container_name: kafka_setup + # build: + # context: ./kafka_setup + # environment: + # - KAFKA_BROKER=kafka:9092 + # networks: + # - botdetector-network + # depends_on: + # kafka: + # condition: service_healthy mysql: container_name: database @@ -92,7 +92,6 @@ services: volumes: - ./src:/project/src depends_on: - - kafka_setup - mysql networks: diff --git a/src/app/repositories/highscore.py b/src/app/repositories/highscore.py index bdc25d9..dac0e9c 100644 --- a/src/app/repositories/highscore.py +++ b/src/app/repositories/highscore.py @@ -31,9 +31,7 @@ async def get(self, id: int): sql = sql.join(target=Player, onclause=self.table.Player_id == Player.id) sql = sql.where(self.table.Player_id == id) data: list[dict] = await self._simple_execute(sql) - for d in data: - d["PlayerHiscoreDataLatest"]["name"] = d.pop("name") - d = d["PlayerHiscoreDataLatest"] + data = [{"name": d.pop("name"), **d["PlayerHiscoreDataLatest"]} for d in data] return data async def get_many(self, start: int, limit: int = 5000): @@ -42,9 +40,8 @@ async def get_many(self, start: int, limit: int = 5000): sql = sql.where(self.table.Player_id > start) sql = sql.limit(limit) data: list[dict] = await self._simple_execute(sql) - for d in data: - d["PlayerHiscoreDataLatest"]["name"] = d.pop("name") - d = d["PlayerHiscoreDataLatest"] + # data = [{"PlayerHiscoreDataLatest":{"total": int, ...}, "name": str}] + data = [{"name": d.pop("name"), **d["PlayerHiscoreDataLatest"]} for d in data] return data async def delete(self, id):