-
Notifications
You must be signed in to change notification settings - Fork 555
feat:Cluster description note #3174
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
| return impl.dbConnection.Update(model) | ||
| } | ||
|
|
||
| func (impl ClusterNoteRepositoryImpl) Delete(model *ClusterNote) error { |
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.
why do we delete, use soft delete
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.
removed delete method 👍
| return clusterNote, err | ||
| } | ||
|
|
||
| func (impl ClusterNoteRepositoryImpl) FindByClusterIds(id []int) ([]ClusterNote, error) { |
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.
use Ids in params
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.
Updated 👍
| return impl.dbConnection.Insert(model) | ||
| } | ||
|
|
||
| func (impl ClusterNoteHistoryRepositoryImpl) FindHistoryByNoteId(id []int) ([]ClusterNoteHistory, error) { |
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.
user pointer * array
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.
Implemented 👍
pkg/cluster/ClusterNoteService.go
Outdated
| if err != nil { | ||
| return err | ||
| } | ||
| return impl.clusterNoteRepository.Delete(model) |
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.
avoid hard delete
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.
removed delete method 👍
pkg/cluster/ClusterNoteService.go
Outdated
| } | ||
| clusterAudit.CreatedBy = userId | ||
| clusterAudit.UpdatedBy = userId | ||
| clusterAudit.CreatedOn = time.Now() |
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.
on update why created by and created on ?
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.
created by and created on is required for saving the record to the audit history
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.
createdBy and CreatedOn for audit logs will not change in update operation.
clusterAudit.CreatedBy = model.Id
clusterAudit.UpdatedBy = model.UpdatedBy
|
SonarCloud Quality Gate failed.
|
pkg/cluster/ClusterNoteService.go
Outdated
| clusterAudit.UpdatedOn = time.Now() | ||
| err = impl.clusterNoteHistoryRepository.SaveHistory(clusterAudit) | ||
| if err != nil { | ||
| return nil, err |
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.
Don't return err, only log it if there is error in saving history
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.
implemented 👍
pkg/cluster/ClusterNoteService.go
Outdated
| } | ||
| clusterAudit.CreatedBy = userId | ||
| clusterAudit.UpdatedBy = userId | ||
| clusterAudit.CreatedOn = time.Now() |
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.
createdBy and CreatedOn for audit logs will not change in update operation.
clusterAudit.CreatedBy = model.Id
clusterAudit.UpdatedBy = model.UpdatedBy
pkg/cluster/ClusterNoteService.go
Outdated
| clusterAudit.UpdatedOn = time.Now() | ||
| err = impl.clusterNoteHistoryRepository.SaveHistory(clusterAudit) | ||
| if err != nil { | ||
| return nil, err |
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.
As user main flow (saving cluster description) is not getting affected by audit logs, don't return error in this case, only log it
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.
implemented 👍
| Description string `json:"description" validate:"required"` | ||
| UpdatedBy int `json:"updated_by"` | ||
| UpdatedOn time.Time `json:"updated_on"` | ||
| } |
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.
is this needed?
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.
yeah this is required for unmarshalling of ClusterNoteRepository
|
|
||
| -- add foreign key | ||
| ALTER TABLE "public"."cluster_note" | ||
| ADD FOREIGN KEY ("cluster_id") REFERENCES "public"."cluster" ("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.
add foreign key in table create query, alter query not required
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.
implemented 👍
| } | ||
| //RBAC enforcer Ends | ||
| bean, err := impl.clusterNoteService.FindByClusterId(i) | ||
| if err != nil { |
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.
use join instead of two queries
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.
implemented 👍
|
SonarCloud Quality Gate failed.
|








Description
Develop GET and PUT methods of Cluster Description.
Cluster Description Fields :
Maintain audit history of cluster description note in database.
Fixes #2773
Tech Doc
How Has This Been Tested?
GET: /description?id={clusterId}
PUT: /description/note
Checklist:
Does this PR introduce a user-facing change?