{"id":29867160,"url":"https://github.com/muchokidavid/loyalty-points-calculator","last_synced_at":"2025-10-28T20:35:35.244Z","repository":{"id":303219771,"uuid":"846793600","full_name":"MuchokiDavid/Loyalty-Points-Calculator","owner":"MuchokiDavid","description":"This project is a Python application that calculates and updates loyalty points based on customer transactions recorded in Google Sheets. The application fetches transaction data, calculates loyalty points, and updates the Google Sheets accordingly. It also keeps track of the last processed entry to avoid duplicating points.","archived":false,"fork":false,"pushed_at":"2025-07-07T12:20:29.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-30T14:02:53.413Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MuchokiDavid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-08-24T01:22:48.000Z","updated_at":"2025-07-07T12:20:32.000Z","dependencies_parsed_at":"2025-07-06T12:40:58.573Z","dependency_job_id":"839faba3-79e7-4ae8-8b30-aab6c2694c0a","html_url":"https://github.com/MuchokiDavid/Loyalty-Points-Calculator","commit_stats":null,"previous_names":["muchokidavid/loyalty-points-calculator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MuchokiDavid/Loyalty-Points-Calculator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MuchokiDavid%2FLoyalty-Points-Calculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MuchokiDavid%2FLoyalty-Points-Calculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MuchokiDavid%2FLoyalty-Points-Calculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MuchokiDavid%2FLoyalty-Points-Calculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MuchokiDavid","download_url":"https://codeload.github.com/MuchokiDavid/Loyalty-Points-Calculator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MuchokiDavid%2FLoyalty-Points-Calculator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281509974,"owners_count":26513981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-30T13:22:20.701Z","updated_at":"2025-10-28T20:35:35.217Z","avatar_url":"https://github.com/MuchokiDavid.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Loyalty Points Calculator\n\nThis project is a Python Flask application that calculates and updates loyalty points based on customer transactions recorded in Google Sheets. The application fetches transaction data, calculates loyalty points, and updates the Google Sheets accordingly. It also keeps track of the last processed entry to avoid duplicating points.\n\n## Features\n\n- Fetch transaction data from Google Sheets.\n- Calculate loyalty points based on the amount paid.\n- Update the Google Sheets with calculated loyalty points.\n- Track the last processed row to prevent duplication.\n- Schedule the loyalty points calculation to run at regular intervals using `APScheduler`.\n\n## Prerequisites\n\n- Python 3.x\n- Google Sheets account\n- Google API credentials JSON file (for accessing Google Sheets)\n\n## Installation\n\n1. **Clone the repository:**\n\n    ```bash\n    git clone https://github.com/muchokidavid/loyalty-points-calculator.git\n    cd loyalty-points-calculator\n    ```\n\n2. **Set up a virtual environment (optional but recommended):**\n\n    ```bash\n    python3 -m venv venv\n    source venv/bin/activate   # On Windows use `venv\\Scripts\\activate`\n    ```\n\n3. **Install the required Python packages:**\n\n    ```bash\n    pip install -r requirements.txt\n    ```\n\n4. **Set up Google API credentials:**\n\n    - Create a Google Cloud project and enable the Google Sheets API.\n    - Download the credentials JSON file.\n    - Save the JSON file in the project directory and rename it to `creds.json`.\n\n5. **Configure your Google Sheets:**\n\n    - Create two Google Sheets:\n      - `Copy of sms loyalty point` - This sheet contains transaction data.\n      - `total points` - This sheet will store the total points for each contact.\n    - Share both sheets with the email address found in the `creds.json` file.\n\n## Usage\n\n1. **Start the Flask application:**\n\n    ```bash\n    python app.py\n    ```\n\n2. **Access the application:**\n\n    Open your web browser and go to `http://localhost:5555/`.\n\n3. **Scheduling:**\n\n    The application automatically calculates and updates loyalty points at regular intervals (every minute, as per the scheduler configuration).\n\n## Project Structure\n\n- `app.py`: The main application file containing the Flask server, functions for fetching and updating data, and loyalty points calculations.\n- `creds.json`: Google API credentials file (not included in the repo, must be provided).\n- `requirements.txt`: A list of Python packages required to run the application.\n\n## Code Overview\n\n- **Flask Application**: Handles HTTP requests and triggers the loyalty points calculation.\n- **Google Sheets Integration**: Uses `gspread` to interact with Google Sheets for reading and updating data.\n- **Loyalty Points Calculation**: A function that calculates new loyalty points and updates the sheet.\n- **Scheduler**: Uses `APScheduler` to schedule the calculation at regular intervals.\n\n## Contributing\n\n1. Fork the repository.\n2. Create a new branch (`git checkout -b feature/your-feature`).\n3. Commit your changes (`git commit -am 'Add your feature'`).\n4. Push to the branch (`git push origin feature/your-feature`).\n5. Create a new Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgements\n\n- [Flask](https://flask.palletsprojects.com/) - Web framework used.\n- [gspread](https://gspread.readthedocs.io/) - Google Sheets Python API.\n- [APScheduler](https://apscheduler.readthedocs.io/) - Advanced Python Scheduler.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuchokidavid%2Floyalty-points-calculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuchokidavid%2Floyalty-points-calculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuchokidavid%2Floyalty-points-calculator/lists"}