Skip to content

Commit 776a7ed

Browse files
committed
Add github action
1 parent c07e8b1 commit 776a7ed

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

.github/workflows/main.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Generate and Publish Database
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v2
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.9'
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -r requirements.txt
26+
27+
- name: Download XML zip file
28+
run: |
29+
curl -O http://ratings.fide.com/download/players_list_xml.zip
30+
31+
- name: Unzip XML file
32+
run: |
33+
unzip players_list_xml.zip -d ./
34+
mv players_list.xml players.xml
35+
36+
- name: Generate SQLite database
37+
run: |
38+
python players.py players.xml players.db
39+
40+
- name: Deploy to Fly.io using Datasette
41+
env:
42+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
43+
run: |
44+
datasette publish fly players.db --app="fide-players" -m metadata.json --token $FLY_API_TOKEN

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@
106106
</div>
107107
<script src="main.js"></script>
108108
</body>
109-
</html>
109+
</html>

main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function fideSelector() {
5656

5757
// Convert URLs to HTTPS
5858
convertToHttps(url) {
59-
if (url.startsWith("http:")) {
59+
if (url && url.startsWith("http:")) {
6060
return url.replace("http://", "https://");
6161
}
6262
return url;
@@ -116,7 +116,7 @@ function fideSelector() {
116116
url.searchParams.append("country__exact", this.selectedCountry);
117117
}
118118
if (this.playerSearch) {
119-
url.searchParams.append("name__contains", this.playerSearch);
119+
url.searchParams.append("_search", this.playerSearch);
120120
}
121121
if (this.sortAsc) {
122122
url.searchParams.append("_sort", this.sortKey);

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
tqdm==4.66.4
2+
datasette
3+
datasette-publish-fly
4+

0 commit comments

Comments
 (0)