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 634023b97b52801e71cffcd7d2483a6beac1b7c2-PR-191

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

Files with Coverage Reduction New Missed Lines %
lib/edgehog/devices.ex 2 95.51%
lib/edgehog/astarte.ex 8 93.5%
Totals Coverage Status
Change from base Build a7808f4b55360659c5259b55f081d3f8659455cb: 0.5%
Covered Lines: 692
Relevant Lines: 827

💛 - 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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Also add relevant tests

Signed-off-by: Riccardo Binetti <[email protected]>
Signed-off-by: Riccardo Binetti <[email protected]>
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 <[email protected]>
Signed-off-by: Riccardo Binetti <[email protected]>
@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