├── assets ├── img │ ├── .gitkeep │ └── favicon.ico ├── js │ ├── script.js │ ├── plugins.js │ └── main.js └── css │ └── style.css ├── bioc_webstats ├── webpack │ └── .gitkeep ├── __init__.py ├── templates │ ├── nav.html │ ├── footer.html │ ├── 500.html │ ├── 404.html │ ├── 401.html │ ├── about.html │ ├── main.css │ ├── home.html │ ├── layout.html │ ├── category.html │ └── stats-bioc.html ├── flask_ingest.sh ├── flask_ingest_crontab_setup.sh ├── app_waitress.py ├── extensions.py ├── static │ ├── cache_manifest.json │ └── barchart.js ├── splash.py ├── database.py ├── ingest_logs.py ├── configmodule.py ├── packages_table_update.py ├── aws_functions.py ├── commands.py ├── app.py └── stats.py ├── tests ├── __init__.py ├── .env ├── factories.py ├── test_models.py └── conftest.py ├── migrations ├── README ├── script.py.mako ├── alembic.ini ├── versions │ └── 9c266b1a4aa9_.py └── env.py ├── .coveragerc ├── e2e ├── constants.ts ├── .env ├── workflow_page.spec.ts └── smoke_test.spec.ts ├── test-deployment ├── ansible │ ├── inventory.ini │ ├── ansible.cfg │ └── install-packages.yml ├── terraform.tfstate.backup ├── terra-development │ ├── main.tf │ └── variables.tf ├── terra-production │ ├── main.tf │ └── variables.tf └── main.tf ├── etl ├── i_populate_web_downloads.sql ├── t_bio _webstats_info.sql ├── postgresql │ ├── u_webstats_info_psql.sql │ ├── t_webstats_info_psql.sql │ ├── t_categorystats_postgres.sql │ ├── t_stats_postgres.sql │ ├── t_packages_postgres.sql │ ├── update_stats.sql │ ├── v_categorystats_postgres.sql │ ├── v_stats_psqlsql.sql │ ├── t_bioc_web_downloads_psql.sql │ ├── f_stats.sql │ └── sp_update_stats.sql ├── change-table-location.json ├── cli_specimens.sh ├── t_stats_parquet.sql ├── t_stats_tsv.sql ├── t_bioc_web_downloads.sql ├── i_populate_category_stats.sql ├── legacy-access_log-to-web_downloads.sql ├── bioc-www-logreader-prod.json ├── legacy-table-def.sql ├── retrieve_package_info.py ├── t_cloudfront_logs.sql ├── s3_move_objects.sh ├── v_bioc_web_downloads.sql ├── t_bioc_web_logs_partitioned.sql └── log_partition_projector.py ├── docs ├── webstats-erd-0_1_9.png ├── design_brief_block_diagram.png ├── bioc-webstats-architecture-v2.excalidraw.png ├── test-instance-setup.md ├── old_specimen.txt ├── webstats-system-overview.md └── stats_replacement_design_brief.md ├── conversion ├── README.md ├── isql_row_counts.sh ├── global_package_history.R ├── global_package_history.py └── access_logs_to_stats_tsv.py ├── dist ├── bioc_webstats-0.1.10-py3-none-any.whl ├── bioc_webstats-0.1.8-py3-none-any.whl └── bioc_webstats-0.1.9-py3-none-any.whl ├── autoapp.py ├── installer_scripts ├── build_docker.sh ├── logrotate.d │ ├── bioc-webstats │ └── README.txt ├── entrypoint.sh ├── bioc-webstats.service ├── apache2.service ├── flask_environment ├── run_docker.sh ├── aws_installer.sh ├── create_ec2_instance.sh ├── Dockerfile ├── docker_dev_setup_example.md └── installer.sh ├── .env.example ├── test-instance-config.py ├── .github └── workflows │ └── playwright.yml ├── .gitignore ├── pyproject.toml ├── playwright.config.ts ├── package.json ├── webpack.config.js └── README.md /assets/img/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bioc_webstats/webpack/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | """Tests for the app.""" 2 | -------------------------------------------------------------------------------- /assets/js/script.js: -------------------------------------------------------------------------------- 1 | // App initialization code goes here 2 | -------------------------------------------------------------------------------- /migrations/README: -------------------------------------------------------------------------------- 1 | Single-database configuration for Flask. 2 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | source = bioc_webstats 3 | omit = 4 | tests/* 5 | 6 | -------------------------------------------------------------------------------- /bioc_webstats/__init__.py: -------------------------------------------------------------------------------- 1 | """Main application package.""" 2 | __version__ = "0.1.8" 3 | -------------------------------------------------------------------------------- /e2e/constants.ts: -------------------------------------------------------------------------------- 1 | // constants.ts 2 | export const URL_STEM = '/packages/stats/'; 3 | -------------------------------------------------------------------------------- /e2e/.env: -------------------------------------------------------------------------------- 1 | # WEBSTATS_URL='http://localhost:5000' 2 | # WEBSTATS_URL='http://3.217.171.126:8000/' -------------------------------------------------------------------------------- /test-deployment/ansible/inventory.ini: -------------------------------------------------------------------------------- 1 | [ec2] 2 | ec2-3-142-133-254.us-east-2.compute.amazonaws.com -------------------------------------------------------------------------------- /test-deployment/ansible/ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | inventory = inventory.ini 3 | remote_user = ubuntu -------------------------------------------------------------------------------- /assets/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/bio-web-stats/devel/assets/img/favicon.ico -------------------------------------------------------------------------------- /etl/i_populate_web_downloads.sql: -------------------------------------------------------------------------------- 1 | insert into bioc_web_downloads 2 | select * 3 | from v_bioc_web_downloads; -------------------------------------------------------------------------------- /assets/js/plugins.js: -------------------------------------------------------------------------------- 1 | // place any jQuery/helper plugins in here, instead of separate, slower script files. 2 | -------------------------------------------------------------------------------- /docs/webstats-erd-0_1_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/bio-web-stats/devel/docs/webstats-erd-0_1_9.png -------------------------------------------------------------------------------- /docs/design_brief_block_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/bio-web-stats/devel/docs/design_brief_block_diagram.png -------------------------------------------------------------------------------- /etl/t_bio _webstats_info.sql: -------------------------------------------------------------------------------- 1 | # TODO operationalize 2 | CREATE TABLE webstats_info 3 | ("key" varchar(23) PRIMARY KEY, 4 | "value" varchar(128)); -------------------------------------------------------------------------------- /conversion/README.md: -------------------------------------------------------------------------------- 1 | This folder contains artifacts for the conversion from the legacy stats.biconductor.org server to the bioc-weblogs system 2 | -------------------------------------------------------------------------------- /dist/bioc_webstats-0.1.10-py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/bio-web-stats/devel/dist/bioc_webstats-0.1.10-py3-none-any.whl -------------------------------------------------------------------------------- /dist/bioc_webstats-0.1.8-py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/bio-web-stats/devel/dist/bioc_webstats-0.1.8-py3-none-any.whl -------------------------------------------------------------------------------- /dist/bioc_webstats-0.1.9-py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/bio-web-stats/devel/dist/bioc_webstats-0.1.9-py3-none-any.whl -------------------------------------------------------------------------------- /autoapp.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """Create an application instance.""" 3 | from bioc_webstats.app import create_app 4 | app = create_app("development") -------------------------------------------------------------------------------- /docs/bioc-webstats-architecture-v2.excalidraw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/bio-web-stats/devel/docs/bioc-webstats-architecture-v2.excalidraw.png -------------------------------------------------------------------------------- /bioc_webstats/templates/nav.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /installer_scripts/build_docker.sh: -------------------------------------------------------------------------------- 1 | # To override execution user:group webstats:webstats, add --build-arg OSUSER="yankee" --build-arg OSGROUP="doddle" 2 | docker build -t webstats-server . 3 | -------------------------------------------------------------------------------- /bioc_webstats/flask_ingest.sh: -------------------------------------------------------------------------------- 1 | # TODO what is the correct directory for this script? 2 | . .venv/bin/activate 3 | export FLASK_APP="bioc_webstats.app:create_app('production', 'bioc/webstats/prod')" 4 | flask ingest -c E1TVLJONPTUXV3 5 | -------------------------------------------------------------------------------- /installer_scripts/logrotate.d/bioc-webstats: -------------------------------------------------------------------------------- 1 | /var/log/bioc-webstats/webstats.log { 2 | weekly 3 | rotate 4 4 | compress 5 | missingok 6 | notifempty 7 | create 0640 ubuntu ubuntu 8 | delaycompress 9 | } 10 | -------------------------------------------------------------------------------- /conversion/isql_row_counts.sh: -------------------------------------------------------------------------------- 1 | # report row counts for all sqlite3 databases 2 | for file in /mnt/data/home/biocadmin/download_dbs/download_db_*.sqlite; do 3 | echo $(basename "$file") $(sqlite3 "$file" "select count(*) from access_log") 4 | done 5 | -------------------------------------------------------------------------------- /etl/postgresql/u_webstats_info_psql.sql: -------------------------------------------------------------------------------- 1 | -- update "Valid through" date 2 | 3 | INSERT INTO webstats_info (key, value) 4 | VALUES ('ValidThru', (SELECT MAX(date) FROM bioc_web_downloads)) 5 | ON CONFLICT (key) 6 | DO UPDATE SET value = EXCLUDED.value; 7 | -------------------------------------------------------------------------------- /test-deployment/terraform.tfstate.backup: -------------------------------------------------------------------------------- 1 | { 2 | "version": 4, 3 | "terraform_version": "1.5.5", 4 | "serial": 5, 5 | "lineage": "ed68b15c-df94-c839-bf44-3a56b77689b5", 6 | "outputs": {}, 7 | "resources": [], 8 | "check_results": null 9 | } 10 | -------------------------------------------------------------------------------- /etl/change-table-location.json: -------------------------------------------------------------------------------- 1 | { 2 | "DatabaseName": "glue-sup-db", 3 | "TableInput": { 4 | "Name": "bw-dev_bioc_weblogs_small_test", 5 | "StorageDescriptor": { 6 | "Location": "s3://dev-bioc-weblogs-small-test/weblogs/" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bioc_webstats/templates/footer.html: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /installer_scripts/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Start systemd as the init system 5 | exec /lib/systemd/systemd 6 | 7 | 8 | # Wait for systemd to start 9 | sleep 5 10 | 11 | # Start ssh service 12 | systemctl start ssh 13 | 14 | # Wait indefinitely to keep the container running 15 | tail -f /dev/null 16 | -------------------------------------------------------------------------------- /tests/.env: -------------------------------------------------------------------------------- 1 | # Environment variable overrides for local development 2 | FLASK_APP=autoapp.py 3 | FLASK_DEBUG=1 4 | FLASK_ENV=development 5 | DATABASE_URL=sqlite:///dev.db 6 | LOG_LEVEL=INFO 7 | SECRET_KEY=012983901238102381038012381298 8 | # In production, set to a higher number, like 31556926 9 | SEND_FILE_MAX_AGE_DEFAULT=0 10 | -------------------------------------------------------------------------------- /test-deployment/terra-development/main.tf: -------------------------------------------------------------------------------- 1 | # development/main.tf 2 | provider "aws" { 3 | region = var.aws_region 4 | } 5 | 6 | # ... 7 | 8 | resource "aws_instance" "example" { 9 | ami = var.ami_id 10 | instance_type = var.instance_type 11 | 12 | tags = { 13 | Name = "development-web-server" 14 | } 15 | } -------------------------------------------------------------------------------- /test-deployment/terra-production/main.tf: -------------------------------------------------------------------------------- 1 | # development/main.tf 2 | provider "aws" { 3 | region = var.aws_region 4 | } 5 | 6 | # ... 7 | 8 | resource "aws_instance" "example" { 9 | ami = var.ami_id 10 | instance_type = var.instance_type 11 | 12 | tags = { 13 | Name = "development-web-server" 14 | } 15 | } -------------------------------------------------------------------------------- /bioc_webstats/flask_ingest_crontab_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # TODO correct directory? 4 | 5 | # Define the script path 6 | SCRIPT_PATH="flask_ingest.sh" 7 | 8 | # Ensure the script is executable 9 | chmod +x $SCRIPT_PATH 10 | 11 | # Add a new cron job 12 | (crontab -l 2>/dev/null; echo "12 1 * * * $SCRIPT_PATH") | crontab - 13 | -------------------------------------------------------------------------------- /installer_scripts/bioc-webstats.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Waitress service for www-webstats 3 | After=network.target 4 | 5 | [Service] 6 | WorkingDirectory=/home/ubuntu 7 | EnvironmentFile=/home/ubuntu/flask_environment 8 | ExecStart=/home/ubuntu/.venv/bin/python3 -m bioc_webstats.app_waitress 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | -------------------------------------------------------------------------------- /test-deployment/terra-development/variables.tf: -------------------------------------------------------------------------------- 1 | # development/variables.tf 2 | variable "aws_region" { 3 | type = string 4 | default = "us-east-2" 5 | } 6 | 7 | variable "ami_id" { 8 | type = string 9 | default = "ami-09d9029d9fc5e5238" 10 | } 11 | 12 | variable "instance_type" { 13 | type = string 14 | default = "t2.micro" 15 | } 16 | -------------------------------------------------------------------------------- /test-deployment/terra-production/variables.tf: -------------------------------------------------------------------------------- 1 | # development/variables.tf 2 | variable "aws_region" { 3 | type = string 4 | default = "us-east-2" 5 | } 6 | 7 | variable "ami_id" { 8 | type = string 9 | default = "ami-09d9029d9fc5e5238" 10 | } 11 | 12 | variable "instance_type" { 13 | type = string 14 | default = "t2.micro" 15 | } 16 | -------------------------------------------------------------------------------- /installer_scripts/logrotate.d/README.txt: -------------------------------------------------------------------------------- 1 | Specimen log rotation configuration for the web app. 2 | 3 | Place the file installer_scripts/logrotate.d/bioc-webstats 4 | on the target system under /etc/logrotate.d/ 5 | 6 | Then set owner to root 7 | sudo chown root:root bioc-webstats 8 | 9 | Test by running: 10 | sudo logrotate -d /etc/logrotate.d/bioc-webstats -------------------------------------------------------------------------------- /bioc_webstats/app_waitress.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from waitress import serve 4 | from bioc_webstats import app 5 | import logging 6 | import sys 7 | 8 | logging.basicConfig(stream=sys.stderr) 9 | 10 | # TODO parameterize port 5000 11 | if __name__ == "__main__": 12 | serve(app.create_app('production', '/bioc/webstats/prod'), host='0.0.0.0', port=8000) -------------------------------------------------------------------------------- /etl/cli_specimens.sh: -------------------------------------------------------------------------------- 1 | aws glue get-table --database-name glue-sup-db --name "bw-dev_bioc_weblogs_small_test" 2 | 3 | aws glue update-table --cli-input-json file://change-table-location.json 4 | 5 | aws glue create-table --database-name glue-sup-db --table-input file://etl/glue_weblog_table_in.json 6 | 7 | aws glue delete-table --database-name glue-sup-db --name bioc_web_logs 8 | -------------------------------------------------------------------------------- /installer_scripts/apache2.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=The Apache HTTP Server 3 | After=network.target remote-fs.target nss-lookup.target 4 | 5 | [Service] 6 | ExecStart=/usr/sbin/apachectl -D FOREGROUND 7 | ExecReload=/usr/sbin/apachectl graceful 8 | ExecStop=/usr/sbin/apachectl stop 9 | Type=notify 10 | PrivateTmp=true 11 | 12 | [Install] 13 | WantedBy=multi-user.target 14 | -------------------------------------------------------------------------------- /test-deployment/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = "us-east-2" # Change this to your desired AWS region 3 | } 4 | 5 | resource "aws_instance" "example" { 6 | ami = "ami-09d9029d9fc5e5238" # Change this to the desired AMI ID 7 | instance_type = "t2.micro" # Change this to the desired instance type 8 | 9 | tags = { 10 | Name = "test-bio-web-stats" 11 | } 12 | } -------------------------------------------------------------------------------- /installer_scripts/flask_environment: -------------------------------------------------------------------------------- 1 | export FLASK_APP="bioc_webstats.app:create_app('production', '/bioc/webstats/prod')" 2 | export FLASK_AWS_PATH_PARAMETER=/bioc/webstats/prod 3 | export FLASK_OSUSER="webstats" 4 | export FLASK_OSGROUP="webstats" 5 | export FLASK_APPROOT="/var/www/bioc-webstats" 6 | export FLASK_LOGROOT="/var/log/bioc-webstats" 7 | export FLASK_AWS_PATH_PARAMETER='/bioc/webstats/prod' 8 | -------------------------------------------------------------------------------- /bioc_webstats/templates/500.html: -------------------------------------------------------------------------------- 1 | 2 | {% extends "layout.html" %} 3 | 4 | {% block page_title %}Server error{% endblock %} 5 | 6 | {% block content %} 7 |
Sorry, something went wrong on our system. Don't panic, we are fixing it! Please try again later.
11 |This template was created by Steven Loria for use with the cookiecutter package by Audrey Roy.
9 || 54 | See download stats for: 55 | {% for ref, desc in category_links %} 56 | Bioconductor {{ desc }} packages 57 | {% endfor %} 58 | | 59 |
{{ url_list }}
63 |64 | Data as of {{ generated_date.strftime("%a. %d %b %Y") }}. 65 |
66 |The number reported next to each package name is the download score, that is, the average number of 67 | distinct IPs that "hit" the package each month for the last 12 months (not counting the current month).
68 | {% if top_count > 0 %} 69 || 75 | 76 | {% set N = top|length // 3 %} 77 | {% for i in range(N) %} 78 | | |
| {{ package_rank }} | 82 |83 | 84 | {{ package_name}} ({{ package_score }}) 85 | 86 | | 87 | {% endfor %} 88 |
98 | All {{ category_name }} package stats in one file: 99 | 100 | {{ tab_page_prefix }}_pkg_stats.tab 101 | 102 |
103 |104 | All {{ category_name }} download scores in one file: 105 | 106 | {{ tab_page_prefix }}_pkg_scores.tab 107 | 108 |
109 |110 | 111 | See Download stats for Bioconductor {{ category_name }} repository (all packages combined) 112 | 113 |
114 | 115 | {% for letterkey, package_list in scores.items() %} 116 |125 | {{ package_name }} ({{ package_score }}) 126 |
127 | {% endfor %} 128 |