Skip to content

Member Counts is a Go app that sends member count data from Redash to Google Chat or Email (via SendGrid).

License

Notifications You must be signed in to change notification settings

RAHB-REALTORS-Association/member-counts-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

55 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CI Build Docker License: MIT

Member Counts

Member Counts is a Go-based application designed to fetch and process member data from Redash and send total member counts to a Google Chat using a Webhook.

πŸ“– Table of Contents

βš™οΈ Configuration

Environment variables are used to configure the application. They can be set in a .env file placed in the project directory or directly in the environment:

  • REDASH_BASE_URL: The base URL of your Redash instance.
  • REDASH_API_KEY: The API key for accessing the Redash API.
  • REDASH_QUERY_ID: The ID of the Redash query to fetch.
  • GOOGLE_CHAT_WEBHOOK_URL: The URL of the Google Chat Webhook.
  • SENDGRID_API_KEY: Your SendGrid API key.
  • SENDER_EMAIL: The From: address of the email.
  • EMAIL_SUBJECT: The Subject: of the email.
  • RECIPIENT_EMAILS: The comma-separated list of email recipients.
  • SCHEDULE_HOUR: The hour to trigger the action.
  • SCHEDULE_MINUTE: The minute to trigger the action.
  • TIMEZONE: Your timezone.

πŸš€ Deployment

Deploy Using PaaS

Deploy to DO

Deploy to Heroku

Build and Run Locally

git clone https://github.com/RAHB-REALTORS-Association/member-counts-go.git
cd member-counts-go
go build

Before running, ensure that the environment variables are correctly set, either in your environment or in a .env file in the project directory.

Run Pre-built Docker Image

docker pull ghcr.io/rahb-realtors-association/member-counts-go:latest
docker run --env-file .env ghcr.io/rahb-realtors-association/member-counts-go:latest

Ensure that the .env file containing the environment variables is present in the directory from which you are running the Docker command.

Building Docker Image Locally

git clone https://github.com/RAHB-REALTORS-Association/member-counts-go.git
cd member-counts-go
docker build -t member-counts-go .
docker run --env-file .env member-counts-go

Again, ensure the .env file is present in your project directory and contains the necessary environment variables before running the Docker image.

πŸ§‘β€πŸ’» Usage

Scheduled Execution

To run the application in a scheduled manner, use the following command:

./member-counts-go

Or, when using Docker:

docker run --env-file .env ghcr.io/rahb-realtors-association/member-counts-go:latest

In these scenarios, the application will remain idle until it reaches the specified hour and minute in your environment or .env file. Once the specified time is hit, the application will:

  1. Refresh the specified Redash query.
  2. Fetch the newly generated data.
  3. Process the data to calculate the total member counts.
  4. Send this count to the specified Google Chat Webhook.

Immediate Execution

For FaaS environments or testing purposes, if you prefer to run the application immediately without waiting for the scheduled time, use the --now flag:

./member-counts-go --now

Or, when using Docker:

docker run --env-file .env ghcr.io/rahb-realtors-association/member-counts-go:latest --now

With the --now flag, the application bypasses the scheduler and executes the aforementioned steps immediately. This is especially useful for testing or when deploying in environments that are ephemeral, like certain FaaS platforms.

Environment Configuration

Before running the application in any environment, ensure that the environment variables are correctly set, either in your environment or in a .env file in the project directory or the directory from which you are running the Docker command.

πŸ› οΈ Tech Stack

The technologies used in this project include:

  • Go 1.17+ 🌿
  • Redash API πŸ“Š
  • Google Chat API πŸ’¬

🌐 Community

Contributing πŸ‘₯

Contributions to Member Counts are warmly welcomed. Please feel free to submit pull requests or open issues to discuss potential modifications or improvements. See our Code of Conduct for community guidelines.

Submit a PR

Reporting Bugs πŸ›

Encountered a bug or have a feature suggestion? Please raise an issue on GitHub with relevant details.

Raise an Issue

πŸ“„ License

This project is open sourced under the MIT license. See the LICENSE file for more info.