Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop into staging, 2024-Jan-30 edition #1282

Merged
merged 32 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ff8e4b6
refactor notation_json_export
jacobdgm Jan 18, 2024
dfa65a9
refactor provenance_json_export
jacobdgm Jan 18, 2024
2b95b2a
Create path for webroot on nginx container build
dchiller Jan 18, 2024
d0a6e1b
Add path to docker-compose.yml in cert renewal cron job
dchiller Jan 18, 2024
41214fe
Merge pull request #1264 from jacobdgm/improve-improve-1251
jacobdgm Jan 19, 2024
209500f
GitHub Actions Broken Link Checker for Production
zhannaklimanova Jan 19, 2024
6091b61
Add `-T` flag to cert renewal cron job
dchiller Jan 19, 2024
fee5e0b
Add -m to cert renewal cron job
dchiller Jan 19, 2024
47b6078
Merge pull request #1270 from dchiller/fix-cert-renewal-cron-cmd
jacobdgm Jan 19, 2024
8908e81
Merge pull request #1272 from DDMAL/broken-link-checker
jacobdgm Jan 19, 2024
7e975e9
Create save_concordances_to_file command
jacobdgm Jan 23, 2024
fa6c811
save_concordances_to_file: improve stdout
jacobdgm Jan 23, 2024
3cc752c
save_concordances_to_file: improve function name
jacobdgm Jan 23, 2024
d8d40c2
add api_cache/ to .gitignore
jacobdgm Jan 23, 2024
7ce3670
refactor save_concordances_to_file
jacobdgm Jan 25, 2024
f32c39e
rename save_concordances_to_file -> update_cached_concordances
jacobdgm Jan 25, 2024
a227ca8
update_cached_concordances: fix bug in chantlink
jacobdgm Jan 25, 2024
a7a0ea0
Add UpdateCachedConcordancesCommandTest
jacobdgm Jan 25, 2024
9716d21
update_cached_concordances: clean up stdout.write
jacobdgm Jan 25, 2024
d18abaf
update_cached_concordances: Clean stdout.write further
jacobdgm Jan 25, 2024
8c855dc
add ujson to requirements.txt
jacobdgm Jan 25, 2024
33b3869
update_cached_concordances: Use ujson.dump instead of json.dump
jacobdgm Jan 25, 2024
7f0859d
update_cached_concordances: use CACHE_DIR while creating FILEPATH
jacobdgm Jan 25, 2024
eff7b0b
Merge pull request #1276 from jacobdgm/1209-concordances-json-to-file
jacobdgm Jan 25, 2024
6f36136
remove break_json.py
jacobdgm Jan 25, 2024
f4db111
parse_link_checker_output.py: update formatting to comply with Black
jacobdgm Jan 25, 2024
c8cb836
remove ijson from requirements
jacobdgm Jan 25, 2024
a1e43f4
remove fixtures-related shell scripts
jacobdgm Jan 25, 2024
9d0daf3
Merge pull request #1277 from jacobdgm/remove-ijson
jacobdgm Jan 25, 2024
b544c17
test_views: Remove superfluous test_chant_with_volpiano_with_no_incipit
jacobdgm Jan 25, 2024
be56951
AjaxSearchBarTest: fix test_cantus_id_search
jacobdgm Jan 25, 2024
5c391bb
Merge pull request #1278 from jacobdgm/clean-up-tests
jacobdgm Jan 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/broken-link-checker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Link checker for articles and flatpages on CantusDB

on:
schedule:
- cron: "8 8 * * 0" # Cron job will run at 08h08 UTC time every Sunday

jobs:
get-all-links:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
BASE_URL="https://cantusdatabase.org"
flatpages=$(curl "$BASE_URL/flatpages-list/" | awk '{ gsub (" ", "\",\"", $0); print}')
articles=$(curl "$BASE_URL/articles-list/" | awk '{ gsub (" ", "\",\"", $0); print}')
list="{\"links\": [\"${flatpages}\",\"${articles}\"]}"
echo $list
echo "matrix=$list" >> $GITHUB_OUTPUT
link-Checker:
runs-on: ubuntu-latest
needs: get-all-links
strategy:
fail-fast: false
max-parallel: 4
matrix: ${{fromJson(needs.get-all-links.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
- name: Link Checker
id: lychee
uses: lycheeverse/[email protected]
with:
args: --exclude http:\/\/cantus\.sk.* ${{ matrix.links }}
format: json
output: /tmp/link-checker-output.txt
- name: Curating Link Checker Output
run: |
echo "***Python Version***"
python --version
echo "***Invoking Parsing Script***"
python "$GITHUB_WORKSPACE/scripts/parse_link_checker_output.py" >> $GITHUB_STEP_SUMMARY
echo "***Printing Summary***"
cat $GITHUB_STEP_SUMMARY
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,7 @@ django/cantusdb_project/Drupal_scripts

# in case you're working on importing data from a database dump
*.sql

# cached files for APIs
api_cache/

2 changes: 1 addition & 1 deletion cron/cron.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
# min hour day month weekday command
0 4 * * * bash /home/ubuntu/code/CantusDB/cron/postgres/db_backup.sh
40 4 1 * * bash /home/ubuntu/code/CantusDB/cron/management/manage.sh populate_next_chant_fields; bash /home/ubuntu/code/CantusDB/cron/management/manage.sh populate_is_last_chant_in_feast
50 4 * * 7 /usr/local/bin/docker-compose exec nginx lego --path /etc/nginx/ssl/live -d cantusdatabase.org -d www.cantusdatabase.org -d mass.cantusdatabase.org --http --http.webroot /var/www/lego/ renew --days 45 --renew-hook "nginx -s reload"
50 4 * * 7 /usr/local/bin/docker-compose -f /home/ubuntu/code/CantusDB/docker-compose.yml exec -T nginx lego --path /etc/nginx/ssl/live -d cantusdatabase.org -d www.cantusdatabase.org -d mass.cantusdatabase.org -m [email protected] --http --http.webroot /var/www/lego/ renew --days 45 --renew-hook "nginx -s reload"
60 changes: 0 additions & 60 deletions django/cantusdb_project/break_json.py

This file was deleted.

56 changes: 0 additions & 56 deletions django/cantusdb_project/create_fixtures.sh

This file was deleted.

46 changes: 0 additions & 46 deletions django/cantusdb_project/load_fixtures.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import ujson
import os
from sys import stdout
from datetime import datetime
from collections import defaultdict
from django.db.models.query import QuerySet
from django.core.management.base import BaseCommand
from main_app.models import Chant


class Command(BaseCommand):
def handle(self, *args, **kwargs) -> None:
CACHE_DIR: str = "api_cache"
FILEPATH: str = f"{CACHE_DIR}/concordances.json"
start_time: str = datetime.now().isoformat()
stdout.write(f"Running update_cached_concordances at {start_time}.\n")
concordances: dict = get_concordances()
write_time: str = datetime.now().isoformat()
metadata: dict = {
"last_updated": write_time,
}
data_and_metadata: dict = {
"data": concordances,
"metadata": metadata,
}
stdout.write(f"Attempting to make directory at {CACHE_DIR} to hold cache: ")
try:
os.mkdir(CACHE_DIR)
stdout.write(f"successfully created directory at {CACHE_DIR}.\n")
except FileExistsError:
stdout.write(f"directory at {CACHE_DIR} already exists.\n")
stdout.write(f"Writing concordances to {FILEPATH} at {write_time}.\n")
with open(FILEPATH, "w") as json_file:
ujson.dump(data_and_metadata, json_file)
end_time = datetime.now().isoformat()
stdout.write(
f"Concordances successfully written to {FILEPATH} at {end_time}.\n\n"
)


def get_concordances() -> dict:
DOMAIN: str = "https://cantusdatabase.org"

stdout.write("Querying database for published chants\n")
published_chants: QuerySet[Chant] = Chant.objects.filter(source__published=True)
values: QuerySet[dict] = published_chants.select_related(
"source",
"feast",
"genre",
"office",
).values(
"id",
"source_id",
"source__siglum",
"folio",
"c_sequence",
"incipit",
"feast__name",
"genre__name",
"office__name",
"position",
"cantus_id",
"image_link",
"mode",
"manuscript_full_text_std_spelling",
"volpiano",
)

stdout.write("Processing chants\n")
concordances: defaultdict = defaultdict(list)
for chant in values:
source_id: int = chant["source_id"]
source_absolute_url: str = f"{DOMAIN}/source/{source_id}/"
chant_id: int = chant["id"]
chant_absolute_url: str = f"{DOMAIN}/chant/{chant_id}/"

concordances[chant["cantus_id"]].append(
{
"siglum": chant["source__siglum"],
"srclink": source_absolute_url,
"chantlink": chant_absolute_url,
"folio": chant["folio"],
"sequence": chant["c_sequence"],
"incipit": chant["incipit"],
"feast": chant["feast__name"],
"genre": chant["genre__name"],
"office": chant["office__name"],
"position": chant["position"],
"cantus_id": chant["cantus_id"],
"image": chant["image_link"],
"mode": chant["mode"],
"full_text": chant["manuscript_full_text_std_spelling"],
"melody": chant["volpiano"],
"db": "CD",
}
)

stdout.write(f"All chants processed - found {len(concordances)} Cantus IDs\n")

return dict(concordances)
Loading
Loading