Skip to content
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

Add support for device tags #191

Merged
merged 9 commits into from
Jun 8, 2022
Merged

Conversation

rbino
Copy link
Collaborator

@rbino rbino commented May 18, 2022

Allow tagging a device, showing its tags when querying it and filtering for a specific tag when requesting the device list.

@coveralls
Copy link

coveralls commented May 18, 2022

Pull Request Test Coverage Report for Build 0f63c3d73fd3e48ba70f72c901e47e24e6a82b3d-PR-191

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 11 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.3%) to 83.13%

Files with Coverage Reduction New Missed Lines %
lib/edgehog/devices.ex 2 95.51%
lib/edgehog/astarte.ex 9 92.74%
Totals Coverage Status
Change from base Build 8b817437e672987c26090863105dfbda0dd8f462: 0.3%
Covered Lines: 680
Relevant Lines: 818

💛 - Coveralls

backend/lib/edgehog/devices/tag.ex Outdated Show resolved Hide resolved
backend/test/edgehog/astarte_test.exs Show resolved Hide resolved
backend/lib/edgehog/devices/device_tag.ex Outdated Show resolved Hide resolved
backend/lib/edgehog/devices/device_tag.ex Show resolved Hide resolved
backend/lib/edgehog/astarte.ex Outdated Show resolved Hide resolved
backend/lib/edgehog/devices.ex Outdated Show resolved Hide resolved
@rbino rbino force-pushed the device-tags branch 2 times, most recently from ac0c414 to 29d2348 Compare May 27, 2022 07:45
Copy link
Contributor

@bettio bettio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add something to the changelog

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Generated with:

mix phx.gen.schema Devices.Tag tags tenant_id:references:tenants \
  name:string:unique

License headers added afterwards

Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
rbino added 8 commits June 1, 2022 13:10
- Use the correct defaults for tenant_id
- Scope the unique_index to :tenant_id additionally
- Add the unique_index on id and tenant_id needed for foreign keys
- Make name not null

Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
Generated with:

mix phx.gen.schema Devices.DeviceTag devices_tags tenant_id:references:tenants \
  tag_id:references:tags device_id:references:devices

License header added after generation.

Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
Rework the schema and migration to accomodate the change:
- No need for a primary key in devices_tags, use a composite one
- Autogenerate tenant_id (use integer since id fields can't have an autogenerate
option)
- Adjust all references to take tenant_id into account

Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
Also add relevant tests

Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
Show tags for the device object and allow updating them with the update_device
mutation. Add all the relevant tests.

Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
@bettio bettio merged commit b1193c2 into edgehog-device-manager:main Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants