-
Notifications
You must be signed in to change notification settings - Fork 1
Use TimescaleDB as database for optimized time series queries #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
by taking the fractions of the hour of first/last date in query
44d0533
to
667548a
Compare
667548a
to
a109a26
Compare
!deploy image |
A docker image of the current pull request was deployed: ghcr.io/maexled/mystrom-django-interface:feature-timescaledb |
!deploy image |
A docker image of the current pull request was deployed: ghcr.io/maexled/mystrom-django-interface:feature-timescaledb |
4c790b2
to
941c6b8
Compare
!deploy image |
A docker image of the current pull request was deployed: ghcr.io/maexled/mystrom-django-interface:feature-timescaledb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR transitions the database backend to TimescaleDB for optimized time-series queries while updating models to support composite primary keys and improving logging and code formatting.
- Updated model definitions for MystromResult using CPkModel with composite primary keys and refined logging.
- Adjusted tests, serializers, and forms to align with revised model and view behaviors.
- Modified Docker, migration, and CI configurations to integrate TimescaleDB and update performance-related settings.
Reviewed Changes
Copilot reviewed 38 out of 38 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
mystrom_rest/tests.py | Updated tests for device creation, deletion, and result queries. |
mystrom_rest/serializers.py | Refactored serializers with updated quoting and formatting. |
mystrom_rest/models.py | Changed CPkModel usage, composite primary keys, and added logging. |
mystrom_rest/migrations/* | Updated migration scripts to support composite keys and hypertables. |
interface/* | Refactored views, URLs, tests, and forms for consistent style. |
docker-compose.yml, Dockerfile | Integrated TimescaleDB and adjusted resource parameters. |
README.md, .env, .github/workflows/* | Updated documentation and CI configurations for TimescaleDB integration. |
Comments suppressed due to low confidence (3)
mystrom_rest/models.py:86
- There is a spelling mistake in the repr output ('deivce_id' should be 'device_id').
return ("<Result(deivce_id='%s', power='%s', ws='%s', relay='%s', temperature='%s', date='%s')>" % (self.device_id, self.power, self.ws, self.relay, self.temperature, self.date))
mystrom_rest/models.py:74
- Using primary_key=True on both the 'date' and 'device' fields is non-standard with Django's ORM. Please verify that the CPkModel integration correctly supports this composite primary key design for reliable ORM operations.
device = models.ForeignKey(MystromDevice, on_delete=models.PROTECT, primary_key=True)
Dockerfile:28
- The increase in gunicorn's --max-requests and --max-requests-jitter settings may affect worker recycling frequency. Please ensure these values have been properly benchmarked to avoid potential stability issues under high load.
CMD ["sh", "-c", "python manage.py makemigrations && python manage.py migrate && python manage.py collectstatic --noinput && gunicorn --bind=0.0.0.0:8000 --timeout 300 --workers=3 --threads=3 --max-requests 20 --max-requests-jitter 5 pim.wsgi:application"]
In Django 5.2 composite primary keys were introduced https://docs.djangoproject.com/en/5.2/topics/composite-primary-key/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the database backend to use TimeScaleDB for optimized time series queries and makes minor code style and dependency updates. Key changes include:
- A new migration that creates a hypertable for the "results" table using TimeScaleDB.
- Adjustments in Docker configuration and documentation to support TimeScaleDB.
- Minor updates in code formatting, tests, and dependency management.
Reviewed Changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
mystrom_rest/migrations/0003_auto_20240720_1432.py | Introduces migration steps to create a hypertable |
mystrom_rest/migrations/0001_initial.py and 0002_mystromdevice_active.py | Minor formatting and quoting improvements |
interface/views.py, urls.py, tests.py, forms.py, apps.py | Consistent quote and formatting updates |
docker-compose.yml, Dockerfile | Updates to Docker configuration and gunicorn parameters; adds TimescaleDB and pgadmin services |
.github/workflows/*.yml, .env, .dockerignore | CI and environment file adjustments for TimeScaleDB support |
!deploy image |
A docker image of the current pull request was deployed: ghcr.io/maexled/mystrom-django-interface:feature-timescaledb |
No description provided.