From 8d0e449484702c8e9db2544072bd8872e0016f81 Mon Sep 17 00:00:00 2001
From: bram-vdberg <bram@cow.fi>
Date: Wed, 30 Oct 2024 13:04:52 +0100
Subject: [PATCH] Fix prefect (#122)

---
 .github/workflows/deploy.yaml    | 13 -------------
 .github/workflows/prefect.yaml   | 27 +++++++++++++++++++++++++++
 src/deploy_prefect/deployment.py |  2 +-
 3 files changed, 28 insertions(+), 14 deletions(-)
 create mode 100644 .github/workflows/prefect.yaml

diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml
index 4a675100..eab75fd0 100644
--- a/.github/workflows/deploy.yaml
+++ b/.github/workflows/deploy.yaml
@@ -32,16 +32,3 @@ jobs:
           push: true
           tags: ${{ steps.meta.outputs.tags }}
           labels: ${{ steps.meta.outputs.labels }}
-
-      - uses: actions/setup-python@v2
-        with:
-          python-version: '3.12'
-
-      - env:
-          PREFECT_API_URL: ${{ secrets.PREFECT_API_URL }}
-      - run: |
-          python -m pip install --upgrade pip
-          pip install -r requirements/prefect.txt
-          pip install -r requirements/prod.txt
-          prefect config set PREFECT_API_URL=$PREFECT_API_URL
-          python -m src.deploy_prefect.deployment
diff --git a/.github/workflows/prefect.yaml b/.github/workflows/prefect.yaml
new file mode 100644
index 00000000..a9773433
--- /dev/null
+++ b/.github/workflows/prefect.yaml
@@ -0,0 +1,27 @@
+name: prefect
+on:
+  push:
+    branches: [ main ]
+jobs:
+  deployment:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: ["3.12"]
+
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set up Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python-version }}
+
+      - name: Deploy prefect deployment
+        env:
+          PREFECT_API_URL: ${{ secrets.PREFECT_API_URL }}
+        run: |
+          python -m pip install --upgrade pip
+          pip install -r requirements/prefect.txt
+          pip install -r requirements/prod.txt
+          prefect config set PREFECT_API_URL=$PREFECT_API_URL
+          python -m src.deploy_prefect.deployment
diff --git a/src/deploy_prefect/deployment.py b/src/deploy_prefect/deployment.py
index f5703370..b13b6c4a 100644
--- a/src/deploy_prefect/deployment.py
+++ b/src/deploy_prefect/deployment.py
@@ -129,7 +129,7 @@ def update_aggregate_query(table_name: str) -> None:
         insertion_point = insertion_point = sql_query.rfind(")")
         updated_sql_query = (
             sql_query[:insertion_point].strip()
-            + f"\n    UNION ALL\n    SELECT * FROM {table_name}\n"
+            + f"\n    UNION ALL\n    SELECT * FROM dune.cowprotocol.dataset_{table_name}\n"
             + sql_query[insertion_point:]
         )
         dune.update_query(  # type: ignore[attr-defined]