Fix infinite bracket on genre with one artist
authorJacob Casper <dev@jacobcasper.com>
Sat, 25 Apr 2020 20:50:01 +0000 (15:50 -0500)
committerJacob Casper <dev@jacobcasper.com>
Sat, 25 Apr 2020 20:50:01 +0000 (15:50 -0500)
frontend/index.js

index 838b623..d70de4f 100644 (file)
@@ -135,7 +135,10 @@ const drawBracket = (canvas, artists, genre) => {
     context.textAlign = "start";
     const [rect_width, rect_height] = getRectangleDimensions(canvas);
     const groups = 4;
-    const rounds = Math.floor(Math.log2(artists.length / groups));
+    const rounds = Math.max(
+        Math.floor(Math.log2(artists.length / groups)),
+        1
+    );
     for (let group = 1; group <= groups; group++) {
             drawMatchup(
                 canvas,