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: description for apps and jobs #3668

Merged
merged 47 commits into from
Jul 27, 2023
Merged

feat: description for apps and jobs #3668

merged 47 commits into from
Jul 27, 2023

Conversation

gireesh-devtron
Copy link
Member

@gireesh-devtron gireesh-devtron commented Jul 21, 2023

Description

Added description for jobs and apps.
Fixes #3700

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit/api test cases.

Does this PR introduce a user-facing change?


@gireesh-devtron gireesh-devtron marked this pull request as ready for review July 24, 2023 18:57
query := "SELECT cl.id AS cluster_id, cl.cluster_name AS cluster_name, cl.created_on AS cluster_created_on, cl.created_by AS cluster_created_by, gn.id AS note_id, gn.description, gn.created_by, gn.created_on, gn.updated_by, gn.updated_on FROM" +
" cluster cl LEFT JOIN" +
" generic_note gn " +
" ON cl.id=gn.identifier AND gn.identifier_type = 0" + //0 is identifier type for cluster description
Copy link
Contributor

Choose a reason for hiding this comment

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

resolve this 0 in Sprintf below

Copy link
Member Author

Choose a reason for hiding this comment

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

done

resp, err := noteHistoryService.Save(tx, testInput, testUserId)
assert.Nil(tt, resp)
assert.NotNil(tt, err)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we checking err != nil ??

Copy link
Member Author

Choose a reason for hiding this comment

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

used assert.NotEqual

resp, err := noteHistoryService.Save(tx, testInput, testUserId)
assert.Nil(tt, err)
assert.NotNil(tt, resp)
if resp == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

use assert.NotEmpty in which u can also pass your failure msg.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

t.Run("Test Success Case", func(tt *testing.T) {
genericNoteSvc, mockedNoteRepo, mockedHistorySvc, mockedUserRepo := initGenericNoteService(t)
tx := &pg.Tx{}
mockedNoteRepo.On("FindByIdentifier", mock.AnythingOfType("int"), mock.AnythingOfType("repository.NoteType")).Return(&repository3.GenericNote{}, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

why aren't we using actual values in params ??

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 880 to 892
if createRequest.Description != nil && createRequest.Description.Description != "" {
descriptionObj := repository3.GenericNote{
Description: createRequest.Description.Description,
IdentifierType: repository3.AppType,
Identifier: app.Id,
}
note, err := impl.genericNoteService.Save(tx, &descriptionObj, createRequest.UserId)
if err != nil {
impl.logger.Errorw("error in saving description", "err", err, "descriptionObj", descriptionObj, "userId", createRequest.UserId)
return nil, err
}
createRequest.Description = note
}
Copy link
Contributor

Choose a reason for hiding this comment

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

put this in func impl.storeDescription

Copy link
Member Author

Choose a reason for hiding this comment

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

done

AlTER TABLE cluster_note DROP CONSTRAINT cluster_note_cluster_id_fkey;
ALTER TABLE cluster_note RENAME to generic_note;
ALTER TABLE generic_note RENAME COLUMN cluster_id to identifier;
ALTER TABLE generic_note ADD COLUMN identifier_type int4 DEFAULT 0 NOT NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't set Default values to existing tables, we should handle it through code.

common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
handler.logger.Infow("request payload, Update", "payload", bean)
Copy link
Contributor

Choose a reason for hiding this comment

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

put its log level to debug

Copy link
Member Author

Choose a reason for hiding this comment

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

done


// RBAC enforcer ends

clusterNoteResponseBean, err := handler.genericNoteService.Update(&bean, userId)
Copy link
Contributor

Choose a reason for hiding this comment

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

rename variable name

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@sonarcloud
Copy link

sonarcloud bot commented Jul 27, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 11 Code Smells

No Coverage information No Coverage information
10.9% 10.9% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@gireesh-devtron gireesh-devtron merged commit 7c9adda into main Jul 27, 2023
3 of 4 checks passed
@gireesh-devtron gireesh-devtron deleted the app_job_description branch July 27, 2023 12:03
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.

Feature: add description fields for apps and jobs in .md format
3 participants