Skip to content

inSPEYERed/cb-statistics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

34 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Commons Booking Statistics Showcase

Commons Booking Statistics ๐Ÿ“Š

Visualize your Commons Booking data. Start here.

Visit the website here where you can upload the timeframes/bookings you've directly exported from within WordPress (see the docs on how to do this). Your data never leaves the browser; it is not uploaded to any server, so you don't have to worry about your privacy and GDPR.


Original Python backend

Originally, this project was only written in Python, plotting with matplotlib and exporting the diagrams as PDFs using PyMuPDF. For the Python project, you had to download some tables from PhpMyAdmin. With the new web app, this is not necessary anymore, just upload your CSV file and that's it. No installation required.

This Python script will help you to get some statistics based on your Commons Booking data. The source code is only intended as a starting point to do your own evaluation (see the file evaluation.py). You might have to adjust the code to get the plots right for your specific dataset, but only small adjustments should be required (e.g. something like: add more colors to a colors array if you have more than three years of data), see this file.

This project is especially helpful if you want to skip the annoying parsing part of the weird database tables posts and postmeta โ€” where the new Commons Booking (starting with version 2) is storing all of the bookings and corresponding data (instead of their lovely old, separate cb_tables beforehand) ...

Usage

Tested with Python 3.10.5:

  • Clone this repo: git clone https://github.com/inSPEYERed/cb-statistics.git.
  • Install the Python requirements: pip install -r requirements.txt.
  • In PhpMyAdmin, export the tables <prefix>_posts and <prefix>_postmeta as JSON files and put them in the ./data/ folder of this project.
  • Create a .env file next to this Readme with the only entry WP_TABLE_PREFIX=<your-table-prefix, e.g. wp>.
  • Run the script via python ./src/main.py.
  • Check the folder ./plots/ to find the output (statistics.pdf has all the statistics combined).

Feel free to open an issue if something is not working for you.

Sample result

Currently supported plots:

  • Bookings per calender week
  • Bookings per weekday
  • Bookings per item

This is how the bookings per weekday result can look like:

cb-statistics-sample-result

License

This program is licensed with the very permissive MIT license, see the LICENSE file for details. As this is only a small project, we don't require you to include the license header in every source file, however you must include it at the root of your project. According to the MIT license you must also include a copyright notice, that is, link back to this project, e.g. in this way:

cb-statistics - Copyright (c) 2022 inSPEYERed

This copyright notice is, however, only needed for source code, not the statistics you rendered with this script.

Any questions regarding the license? This FAQ might help. This project is not endorsed by the official Commons Booking.