This project provides a script to fetch and analyse the trending Homebrew casks and formulas. It uses DuckDB for data processing and analysis.
-
Clone the repository:
git clone https://github.com/yourusername/brew_trend.git cd brew_trend
-
Run the build script:
sh brew_trend/build.sh
This script performs the following actions:
- Fetches the latest data from Homebrew's API.
- Saves the data to temporary files.
- Constructs a SQL query to analyse the data using DuckDB.
-
The script will output the results of the analysis, showing the trending casks and formulas based on the search term provided.
The trending.sql script performs the following tasks:
- Installs and loads the Full-Text Search (FTS) extension in DuckDB.
- Creates tables for casks and formulas by reading JSON data.
- Creates a
corpustable that combines casks and formulas for full-text search. - Creates an FTS index on the
corpustable. - Creates a
brew_analyticstable by reading analytics data from JSON files. - Creates a
categoriestable to categorise and count installs. - Creates an
installstable to pivot install counts. - Creates a
measurestable to calculate average installs and trend changes. - Performs a full-text search on the
corpustable based on the search term. - Joins the search results with the
measurestable to calculate scaled scores and distances. - Outputs the final results ordered by relevance.
To search for a specific term, modify the search_term variable in the build.sh script:
echo "SET VARIABLE search_term = 'your_search_term';" > /tmp/brew_trend/term.sqlReplace 'your_search_term' with the term you want to search for.
This project is licensed under the MIT Licence.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.