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

feat(admin) targets can be deleted by their ID #2304

Merged
merged 2 commits into from Mar 31, 2017
Merged

Conversation

subnetmarco
Copy link
Member

Full changelog

  • Extends the sugar DELETE method for upstream targets, allowing them to be deleted by id as well.

return helpers.yield_error(err)
end

-- We know username and id are unique, so if we have a row, it must be the only one
Copy link
Member

Choose a reason for hiding this comment

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

comment needs an update

@subnetmarco
Copy link
Member Author

Updated.

end,

DELETE = function(self, dao_factory)
clean_history(self.upstream.id, dao_factory)

-- this is just a wrapper around POSTing a new target with weight=0
local data, err = dao_factory.targets:insert({
target = self.params.target,
target = self.target.target,
Copy link
Member Author

Choose a reason for hiding this comment

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

The target field name is confusing with the target entity, should be really called address ("Targets can have an address and a weight" as opposed to "Targets can have a target and a weight")

@Tieske

Copy link
Contributor

Choose a reason for hiding this comment

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

We have a target object and a target field. Sounds like we need a breaking API change then?

Copy link
Member

Choose a reason for hiding this comment

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

not worth it imo

Copy link
Contributor

Choose a reason for hiding this comment

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

(also out of scope for the PR ;) )

Copy link
Member Author

Choose a reason for hiding this comment

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

Not in this PR of course - just a consideration that it's a confusing naming.

return helpers.yield_error(err)
end

-- We know target and id are unique, so if we have a row, it must be the only one
Copy link
Contributor

Choose a reason for hiding this comment

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

overly pedantic, nonblocking note on this comment "we know target and id are unique" - to what does id refer to here? the id of the target? the upstream?

also, certainly target is not unique in this case. :)

Copy link
Member

Choose a reason for hiding this comment

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

should be we can have multiple targets here, but anyone will do as they all have the same 'target' field, so just pick the first

Copy link
Member Author

Choose a reason for hiding this comment

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

Which makes me wonder, should it be unique? Currently I can have three times a Target with the same target and weight > 0, but does it make sense?

Should we check that every time you add a Target, if a Target with weight > 0 and same target already exists, then return 409 Conflict?

Copy link
Member

Choose a reason for hiding this comment

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

no, the new one overrides the old one, but the old one must be preserved in the history

Copy link
Member Author

Choose a reason for hiding this comment

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

Problem is, calling /targets/active/ still shows all of them, not just the last one, which doesn't make it clear if all of them are active or just the last one.

Copy link
Member

Choose a reason for hiding this comment

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

that does not matter, because all of those records might differ on the weight property, but they will all have the same target field, and thats the field you're looking for.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Tieske @p0pr0ck5 we found a bug in /targets/active/ that was confusing me. Opening an issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

#2306 (and another minor one at #2305)

Copy link
Contributor

Choose a reason for hiding this comment

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

both of these issues addressed with PRs- we still need to resolve the erroneous comment :)

@Tieske Tieske merged commit a530178 into master Mar 31, 2017
@Tieske Tieske deleted the feat/delete-target-by-id branch March 31, 2017 07:12
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.

None yet

3 participants