Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Brew Trend

This project provides a script to fetch and analyse the trending Homebrew casks and formulas. It uses DuckDB for data processing and analysis.

Prerequisites

  • DuckDB installed on your system.
  • curl installed on your system.

Setup

  1. Clone the repository:

    git clone https://github.com/yourusername/brew_trend.git
    cd brew_trend

Usage

  1. 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.
  2. The script will output the results of the analysis, showing the trending casks and formulas based on the search term provided.

SQL Script

The trending.sql script performs the following tasks:

  1. Installs and loads the Full-Text Search (FTS) extension in DuckDB.
  2. Creates tables for casks and formulas by reading JSON data.
  3. Creates a corpus table that combines casks and formulas for full-text search.
  4. Creates an FTS index on the corpus table.
  5. Creates a brew_analytics table by reading analytics data from JSON files.
  6. Creates a categories table to categorise and count installs.
  7. Creates an installs table to pivot install counts.
  8. Creates a measures table to calculate average installs and trend changes.
  9. Performs a full-text search on the corpus table based on the search term.
  10. Joins the search results with the measures table to calculate scaled scores and distances.
  11. Outputs the final results ordered by relevance.

Example

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.sql

Replace 'your_search_term' with the term you want to search for.

Licence

This project is licensed under the MIT Licence.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

Acknowledgements

  • Homebrew for providing the API data.
  • DuckDB for the powerful data processing capabilities.

About

Analyse the trending Homebrew casks and formulas

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages