-
Notifications
You must be signed in to change notification settings - Fork 671
MF-983 - Add HTTP query param to connections list endpoints to fetch disconnected Things or Channels #1217
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
…non 8000 connected Things or Channels Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
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.
swagger needs update
@manuio Please update PR, CI is failing and the branch is out of date. |
Codecov Report
@@ Coverage Diff @@
## master #1217 +/- ##
=========================================
Coverage ? 76.38%
=========================================
Files ? 106
Lines ? 6963
Branches ? 0
=========================================
Hits ? 5319
Misses ? 1259
Partials ? 385
Continue to review full report at Codecov.
|
@manuio IMHO |
@nmarcetic do you mean to return connected by default? And disconnected if connected = false? If we return connected and disconnected we are returning all things :) I wanted a flag where the default value is false to simplify the code. Maybe we can find a better naming. |
@manuio Yes, return all things owned by user by default. then filter it with a query like &connected=true/false if you want. We have pagination. This would be the cleanest way. |
@nmarcetic Why would I specify a channel or thing ID ( |
@manuio Why would you specify ID ( Ok, keep it as is, I think |
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.
I agree with @nmarcetic that using connected
param is better than disconnected
.
things/api/things/http/transport.go
Outdated
offsetKey = "offset" | ||
limitKey = "limit" | ||
nameKey = "name" | ||
metadataKey = "metadata" | ||
disconKey = "disconnected" |
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.
I prefer the old naming.
things/postgres/things.go
Outdated
LIMIT :limit | ||
OFFSET :offset;` | ||
FROM things th | ||
INNER JOIN connections co |
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.
Using conn
instead of co
is less ambiguous.
things/postgres/things.go
Outdated
ORDER BY th.id | ||
LIMIT :limit | ||
OFFSET :offset;` | ||
FROM things th |
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.
You can use switch
here, it's cleaner than using if
.
things/postgres/channels.go
Outdated
LIMIT :limit | ||
OFFSET :offset` | ||
q := `SELECT id, name, metadata FROM channels ch | ||
INNER JOIN connections co ON ch.id = co.channel_id |
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.
this doesnt look properly aligned
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
things/mocks/channels.go
Outdated
channels = append(channels, co) | ||
} | ||
} | ||
} else { |
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.
Can you avoid using else
?
things/postgres/things.go
Outdated
ORDER BY th.id | ||
LIMIT :limit | ||
OFFSET :offset;` | ||
var q string |
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.
Same here.
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.
Same remark for indentation.
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
things/postgres/channels.go
Outdated
ORDER BY ch.id | ||
LIMIT :limit | ||
OFFSET :offset` | ||
var q string |
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.
You can use var q, qc string
.
things/postgres/things.go
Outdated
ORDER BY th.id | ||
LIMIT :limit | ||
OFFSET :offset;` | ||
var q string |
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.
Same remark for indentation.
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
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.
LGTM
…disconnected Things or Channels (#1217) * MF-983 - Add HTTP query param to connections list endpoints to fetch non connected Things or Channels Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typos and add Swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Update SDK and CLI Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Simplify queries Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix tabulation Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
Signed-off-by: Manuel Imperiale manuel.imperiale@gmail.com
Resolves #983