diff --git a/.github/workflows/update_to_dune.yml b/.github/workflows/update_to_dune.yml deleted file mode 100644 index 5ab9f25..0000000 --- a/.github/workflows/update_to_dune.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Update to Dune on Commit (Push Queries) - -on: - push: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-python@v4 - with: - python-version: '3.9' - - - name: Log directory structure - run: | - pwd - ls -R - - - name: pip requirements - run: pip install -r requirements.txt - - - name: Update all queries from Dune - env: - DUNE_API_KEY: ${{ secrets.DUNE_API_KEY }} - run: python -u scripts/update_to_dune.py - - \ No newline at end of file diff --git a/README.md b/README.md index d696d1e..ee12db7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ A template for creating repos to manage your Dune queries using the CRUD API. ### Setup -1. First, go to the dashboard you want to create a repo for (must be owned by you/your team). Click on the "github" icon in the top right to get a popup which will display all your query ids for said dashboard. Or, just get the list queries you want to track in general. +1. First, go to the dashboard you want to create a repo for (must be owned by you/your team). Click on the "github" icon in the top right to get a popup which will display all your query ids for said dashboard. + - Alternatively, just get the list queries you want to track if you aren't doing this for a dashboard. 2. Copy and paste that list into the `queries.yml` file. diff --git a/queries/query_3237721.sql b/queries/query_3237721.sql index b1ecc8d..0298460 100644 --- a/queries/query_3237721.sql +++ b/queries/query_3237721.sql @@ -1,6 +1,3 @@ --- DEX by volume 🏦 --- https://dune.com/queries/3237721 - WITH seven_day_volume AS ( SELECT diff --git a/queries/query_3237723.sql b/queries/query_3237723.sql index 1d8cce0..568cdc1 100644 --- a/queries/query_3237723.sql +++ b/queries/query_3237723.sql @@ -1,7 +1,3 @@ --- Weekly DEX volume by chain --- https://dune.com/queries/3237723 - - SELECT blockchain, DATE_TRUNC('week', block_time), diff --git a/queries/query_3237726.sql b/queries/query_3237726.sql index 4d996fd..851be75 100644 --- a/queries/query_3237726.sql +++ b/queries/query_3237726.sql @@ -1,7 +1,3 @@ --- Aggregator by volume 📢 --- https://dune.com/queries/3237726 - - WITH seven_day_volume AS ( SELECT diff --git a/queries/query_3237738.sql b/queries/query_3237738.sql index 3af3aee..8b5c65d 100644 --- a/queries/query_3237738.sql +++ b/queries/query_3237738.sql @@ -1,7 +1,3 @@ --- Weekly DEX volume --- https://dune.com/queries/3237738 - - SELECT project, DATE_TRUNC('week', block_time), diff --git a/queries/query_3237742.sql b/queries/query_3237742.sql index b049bb2..f2d5ec2 100644 --- a/queries/query_3237742.sql +++ b/queries/query_3237742.sql @@ -1,7 +1,3 @@ --- Weekly DEX Aggregator volume --- https://dune.com/queries/3237742 - - SELECT project, DATE_TRUNC('week', block_time), diff --git a/queries/query_3237745.sql b/queries/query_3237745.sql index acad8a6..d2d8a49 100644 --- a/queries/query_3237745.sql +++ b/queries/query_3237745.sql @@ -1,7 +1,3 @@ --- EVM DEX Traders by Bucket --- https://dune.com/queries/3237745 - - with all_traders as ( SELECT diff --git a/scripts/update_from_dune.py b/scripts/update_from_dune.py index b5c2140..26802f5 100644 --- a/scripts/update_from_dune.py +++ b/scripts/update_from_dune.py @@ -28,13 +28,16 @@ file_path = os.path.join(os.path.dirname(__file__), '..', 'queries', f'query_{query.base.query_id}.sql') if os.path.exists(file_path): # Update existing file - with open(file_path, 'r+', encoding='utf-8') as file: - file.truncate(0) # Delete all file contents - file.write(f'-- {query.base.name}\n-- https://dune.com/queries/{query.base.query_id}\n\n\n{query.sql}') + with open(file_path, 'r+', encoding='utf-8') as file: + #if "query repo:" is in the file, then don't add the text header again + if '-- already part of a query repo' in query.sql: + file.write(query.sql) + else: + file.write(f'-- already part of a query repo\n --query name: {query.base.name}\n-- query link: https://dune.com/queries/{query.base.query_id}\n\n\n{query.sql}') else: # Create new file and directories if they don't exist os.makedirs(os.path.dirname(file_path), exist_ok=True) with open(file_path, 'w', encoding='utf-8') as file: - file.write(f'-- {query.base.name}\n-- https://dune.com/queries/{query.base.query_id}\n\n\n{query.sql}') + file.write(f'-- already part of a query repo\n --query name: {query.base.name}\n-- query link: https://dune.com/queries/{query.base.query_id}\n\n\n{query.sql}')