From 776a7edd2202565d6f7011468f5a2e0ce3ef67fd Mon Sep 17 00:00:00 2001 From: Marc Farra Date: Thu, 30 May 2024 20:42:21 +0300 Subject: [PATCH] Add github action --- .github/workflows/main.yml | 44 ++++++++++++++++++++++++++++++++++++++ index.html | 2 +- main.js | 4 ++-- requirements.txt | 3 +++ 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b12c663 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,44 @@ +name: Generate and Publish Database + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.9' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Download XML zip file + run: | + curl -O http://ratings.fide.com/download/players_list_xml.zip + + - name: Unzip XML file + run: | + unzip players_list_xml.zip -d ./ + mv players_list.xml players.xml + + - name: Generate SQLite database + run: | + python players.py players.xml players.db + + - name: Deploy to Fly.io using Datasette + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} + run: | + datasette publish fly players.db --app="fide-players" -m metadata.json --token $FLY_API_TOKEN diff --git a/index.html b/index.html index cf3369f..0c4b7b3 100644 --- a/index.html +++ b/index.html @@ -106,4 +106,4 @@ - \ No newline at end of file + diff --git a/main.js b/main.js index 2a87792..4c4965b 100644 --- a/main.js +++ b/main.js @@ -56,7 +56,7 @@ function fideSelector() { // Convert URLs to HTTPS convertToHttps(url) { - if (url.startsWith("http:")) { + if (url && url.startsWith("http:")) { return url.replace("http://", "https://"); } return url; @@ -116,7 +116,7 @@ function fideSelector() { url.searchParams.append("country__exact", this.selectedCountry); } if (this.playerSearch) { - url.searchParams.append("name__contains", this.playerSearch); + url.searchParams.append("_search", this.playerSearch); } if (this.sortAsc) { url.searchParams.append("_sort", this.sortKey); diff --git a/requirements.txt b/requirements.txt index d69c960..b308eef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,4 @@ tqdm==4.66.4 +datasette +datasette-publish-fly +