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

Notification Framework Update #276

Merged
merged 2 commits into from
Jan 22, 2020
Merged

Notification Framework Update #276

merged 2 commits into from
Jan 22, 2020

Conversation

sf2ne
Copy link
Collaborator

@sf2ne sf2ne commented Jan 22, 2020

This PR includes:

  • When nodes call the /changes route they will only receive node updates about themselves and not any other nodes.

qOrg = for {
r <- ResourceChangesTQ.rows.filter(_.orgId === orgId).filter(_.lastUpdated >= lastTime).filter(_.changeId >= reqBody.changeId).filter(u => u.category === "node" && u.id === ident.getIdentity)
} yield (r.changeId, r.orgId, r.id, r.category, r.public, r.resource, r.operation, r.lastUpdated)
case _ => qOrg = qOrg
Copy link
Member

Choose a reason for hiding this comment

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

Why do this assignment in this case? You can just use ; when you have nothing to do in a case.

ident match {
case _: INode =>
qOrg = for {
r <- ResourceChangesTQ.rows.filter(_.orgId === orgId).filter(_.lastUpdated >= lastTime).filter(_.changeId >= reqBody.changeId).filter(u => u.category === "node" && u.id === ident.getIdentity)
Copy link
Member

Choose a reason for hiding this comment

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

To avoid having to repeat all of the filter logic, you could first save the main filters with:

var qOrgQuery = ResourceChangesTQ.rows.filter(_.orgId === orgId).filter(_.lastUpdated >= lastTime).filter(_.changeId >= reqBody.changeId)

And then in the case of ident being an INode:

qOrgQuery = qOrgQuery.filter(u => u.category === "node" && u.id === ident.getIdentity)

But won't that filter also filter out everything not a node? Shouldn't it be:

qOrgQuery = qOrgQuery.filter(u => (u.category === "node" && u.id === ident.getIdentity) || u.category =!= "node")

Once you have that settled, then use it in the for/yield statement:

ar qOrg = for {
  r <- qOrgQuery
} yield (r.changeId, r.orgId, r.id, r.category, r.public, r.resource, r.operation, r.lastUpdated)

@sf2ne
Copy link
Collaborator Author

sf2ne commented Jan 22, 2020

e2edev passed!

@sf2ne sf2ne merged commit 14d320b into open-horizon:master Jan 22, 2020
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.

2 participants