{"id":24650612,"url":"https://github.com/ujitkumar1/storemonitoring","last_synced_at":"2026-04-09T17:58:32.495Z","repository":{"id":188285879,"uuid":"678451972","full_name":"ujitkumar1/StoreMonitoring","owner":"ujitkumar1","description":"A Python app for generating and managing store reports through RestAPIs","archived":false,"fork":false,"pushed_at":"2023-08-14T17:57:06.000Z","size":96,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T18:16:10.841Z","etag":null,"topics":["flask","flask-restful","python3","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ujitkumar1.png","metadata":{"files":{"readme":"readME.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-14T15:28:37.000Z","updated_at":"2023-08-14T15:33:31.000Z","dependencies_parsed_at":"2023-08-14T18:53:35.566Z","dependency_job_id":null,"html_url":"https://github.com/ujitkumar1/StoreMonitoring","commit_stats":null,"previous_names":["ujitkumar1/storemonitoring"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujitkumar1%2FStoreMonitoring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujitkumar1%2FStoreMonitoring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujitkumar1%2FStoreMonitoring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujitkumar1%2FStoreMonitoring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ujitkumar1","download_url":"https://codeload.github.com/ujitkumar1/StoreMonitoring/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244686321,"owners_count":20493425,"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","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":["flask","flask-restful","python3","rest-api"],"created_at":"2025-01-25T18:16:11.979Z","updated_at":"2025-12-30T22:48:36.722Z","avatar_url":"https://github.com/ujitkumar1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Store Monitoring API: A Python app for generating and managing store reports\n\n## Description\n\nThis RESTful API, built with Python Flask and Celery, enables users to trigger and generate store reports\nasynchronously. The reports contain information about various stores, their timezones, and relevant data. Users can also\nretrieve the generated reports for analysis.\n\n## Prerequisites\n\nBefore using this application, ensure you have the following prerequisites:\n\n1. Python Programming Language\n2. MySQL\n3. Flask\n4. Flask-RESTful\n5. JSON\n6. Redis\n7. Celery\n\n## Installation\n\nTo install the required packages and libraries, run the following command in your terminal:\n\n```\npip install -r requirements.txt\n```\n\nThis command will install all the necessary dependencies listed in the requirements.txt file, allowing you to run the\nproject without any issues.\n\n### Usage:\n\n1. Start the application by running the following command in the project directory:\n\n```\npython main.py\n```\nor \n\n```\npython3 main.py\n```\n\nThis will start the application, and you should be able to use it. (or) Directly run the main.py file by defalt the url\nof application would be : http://127.0.0.1:5000\n\n2. To run Celery and Redis, execute the following commands in separate terminal (for windows use WSL)\n\n```\nredis-server\ncelery -A app.celery worker -l info\n```\n\nThis will start the Redis server and the Celery worker to enable asynchronous task processing.\n\n#### Endpoint Working:\n\n1. **Trigger Report Generation**:\n\n    - Endpoint: /trigger_report\n    - Description: Trigger the generation of a store report.\n    - Method: POST\n    - Example Request:```POST http://127.0.0.1:5000/trigger_report```\n    - Example Response:\n    - ```{\"report_id\": \"5e379ee1\"}```\n\n\n2. **Get Generated Report**:\n\n    - Endpoint: /get_report/\u003cstring:report_id\u003e\n    - Description: Retrieve a generated store report.\n    - Method: GET\n    - Example Request: ```GET http://127.0.0.1:5000/get_report/5e379ee1```\n    - Example Response (Report Generation in Progress):\n    - ```{\"Status\": \"Running\"}```\n    - Example Response (Report Generation Completed):\n    - ```{\"Status\": \"Completed\",\"Path\": \"report/5e379ee1.csv\"}```\n\n### logic for computing the hours\n\n1. The function calculate_uptime_downtime is responsible for calculating the uptime and downtime of a store within a\n   specific time period.\n\n2. It takes three arguments: store_id (the ID of the store), start_time (the beginning of the time period), and\n   end_time (the end of the time period).\n\n3. Inside the function:\n\n- It first retrieves the business hours of the store using the MenuHours table from the database.\n- It initializes variables to keep track of the total business hours, total uptime, and total downtime.\n\n4. The function then goes through each business hour for the store and checks if there's an overlap between the business\n   hour and the specified time period.\n\n5. If an overlap exists:\n\n- It calculates the duration of the overlap in seconds.\n- Adds this overlap duration to the total business hours.\n- It simulates retrieving the store's status during this overlap from the get_store_status function. If the store is\n  active during this time, it adds the overlap duration to the total uptime.\n\n6. Finally, the function calculates the total downtime by subtracting the total uptime from the total business hours.\n\n7. The calculated total uptime and total downtime are returned as a tuple.\n\n8. If any error occurs during this process, it is caught, and an error message is logged.\n\nThis function essentially helps determine the time the store was operational (uptime) and the time it was not\noperational (downtime) within a given time period, considering its business hours and status.\n\n### Project Demo Link\n\nGoogle Drive Video Link : https://drive.google.com/file/d/1u8gWrd5zZty1A4ON-dEkecN029naHln4/view?usp=sharing\n\n### Contact:\n\n**Name** : Ujit Kumar\n\n**Email** : ujitkumar1@gmail.com\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fujitkumar1%2Fstoremonitoring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fujitkumar1%2Fstoremonitoring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fujitkumar1%2Fstoremonitoring/lists"}