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

Add #201 Ability to configure default organisation and types on initi… #203

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

albinpa
Copy link
Contributor

@albinpa albinpa commented Oct 6, 2023

…al start of the application if not existing

@albinpa albinpa added the enhancement New feature or request label Oct 6, 2023
@albinpa albinpa self-assigned this Oct 6, 2023
Copy link
Member

@georgepadayatti georgepadayatti left a comment

Choose a reason for hiding this comment

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

  1. Create/update organisation and type

)

// AddOrganization Adds an organization
func AddOrganization(orgReq config.Organization, userId string) (org.Organization, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Move this function to organizations.go file under org package.

common.HandleError(w, http.StatusBadRequest, m, err)
return
}
if count > 1 {
_, err := org.DeleteAllOrganizations()
Copy link
Member

Choose a reason for hiding this comment

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

Move this logic to main.go ?


// checking if the string contained whitespace only
if strings.TrimSpace(orgReq.Name) == "" {
log.Printf("Failed to add organization: Missing mandatory param - Name")
Copy link
Member

Choose a reason for hiding this comment

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

Application should exit if organisation configuration is invalid.

@@ -138,7 +138,7 @@ func GetOrganizationByID(w http.ResponseWriter, r *http.Request) {
func GetOrganizationId() (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Move this to org package

@@ -138,7 +138,7 @@ func GetOrganizationByID(w http.ResponseWriter, r *http.Request) {
func GetOrganizationId() (string, error) {
org, err := org.GetOrganization()
Copy link
Member

Choose a reason for hiding this comment

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

Rename this to GetFirstOrganization

@@ -660,3 +660,25 @@ func GetName(organizationID string) (string, error) {

return result.Name, err
}

// GetOrganizationCount Get organization count
func GetOrganizationCount() (int64, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Rename to GetOrganizationsCount

@@ -138,7 +138,7 @@ func GetOrganizationByID(w http.ResponseWriter, r *http.Request) {
func GetOrganizationId() (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Rename to GetFirstOrganisation

@albinpa albinpa force-pushed the feature/201-configure-default-organization branch from 467aed5 to c04ed48 Compare October 10, 2023 13:18
Copy link
Member

@georgepadayatti georgepadayatti left a comment

Choose a reason for hiding this comment

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

Can you remove all the unused code ?

}

type OrgType struct {
Type string `valid:"required"`
Copy link
Member

Choose a reason for hiding this comment

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

Rename this to name

return orgResp, err
}

func IsOrganizationUpdateRequired(org Organization, orgReq config.Organization, typeName string) bool {
Copy link
Member

Choose a reason for hiding this comment

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

@albinpa We don't need this anymore ?

}

// UpdateOrganization Updates an organization
func UpdateOrganization(org Organization, orgReq config.Organization, orgType orgtype.OrgType) (Organization, error) {
Copy link
Member

Choose a reason for hiding this comment

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

@albinpa We don't need this anymore ?

}

// UpdateOrganizationType Updates an organization type
func UpdateOrganizationType(orgType OrgType, typeReq config.OrgType) (OrgType, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this ?

@albinpa albinpa force-pushed the feature/201-configure-default-organization branch from c04ed48 to f0a352a Compare October 11, 2023 04:41
@georgepadayatti georgepadayatti merged commit 141cc7c into main Oct 11, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants