refactor to respect naming convention

This commit is contained in:
Massaki Archambault 2024-08-08 23:44:12 -04:00
parent 367d770371
commit c8f3de248f
3 changed files with 16 additions and 16 deletions

View File

@ -63,8 +63,8 @@ func (c *githubClient) FetchRootGroupContent() (map[string]fstree.GroupSource, e
if c.rootContent == nil {
rootContent := make(map[string]fstree.GroupSource)
for _, org_name := range c.GithubClientConfig.OrgNames {
org, err := c.fetchOrganization(org_name)
for _, orgName := range c.GithubClientConfig.OrgNames {
org, err := c.fetchOrganization(orgName)
if err != nil {
c.logger.Warn(err.Error())
} else {
@ -72,8 +72,8 @@ func (c *githubClient) FetchRootGroupContent() (map[string]fstree.GroupSource, e
}
}
for _, user_name := range c.GithubClientConfig.UserNames {
user, err := c.fetchUser(user_name)
for _, userName := range c.GithubClientConfig.UserNames {
user, err := c.fetchUser(userName)
if err != nil {
c.logger.Warn(err.Error())
} else {

View File

@ -31,26 +31,26 @@ func (o *Organization) InvalidateContentCache() {
o.childRepositories = nil
}
func (c *githubClient) fetchOrganization(org_name string) (*Organization, error) {
func (c *githubClient) fetchOrganization(orgName string) (*Organization, error) {
c.organizationCacheMux.RLock()
cachedId, found := c.organizationNameToIDMap[org_name]
cachedId, found := c.organizationNameToIDMap[orgName]
if found {
cachedOrg := c.organizationCache[cachedId]
c.organizationCacheMux.RUnlock()
// if found in cache, return the cached reference
c.logger.Debug("Organization cache hit", "org_name", org_name)
c.logger.Debug("Organization cache hit", "org_name", orgName)
return cachedOrg, nil
} else {
c.organizationCacheMux.RUnlock()
c.logger.Debug("Organization cache miss", "org_name", org_name)
c.logger.Debug("Organization cache miss", "org_name", orgName)
}
// If not found in cache, fetch organization infos from API
githubOrg, _, err := c.client.Organizations.Get(context.Background(), org_name)
githubOrg, _, err := c.client.Organizations.Get(context.Background(), orgName)
if err != nil {
return nil, fmt.Errorf("failed to fetch organization with name %v: %v", org_name, err)
return nil, fmt.Errorf("failed to fetch organization with name %v: %v", orgName, err)
}
newOrg := Organization{
ID: *githubOrg.ID,

View File

@ -31,26 +31,26 @@ func (u *User) InvalidateContentCache() {
u.childRepositories = nil
}
func (c *githubClient) fetchUser(user_name string) (*User, error) {
func (c *githubClient) fetchUser(userName string) (*User, error) {
c.userCacheMux.RLock()
cachedId, found := c.userNameToIDMap[user_name]
cachedId, found := c.userNameToIDMap[userName]
if found {
cachedUser := c.userCache[cachedId]
c.userCacheMux.RUnlock()
// if found in cache, return the cached reference
c.logger.Debug("User cache hit", "user_name", user_name)
c.logger.Debug("User cache hit", "user_name", userName)
return cachedUser, nil
} else {
c.userCacheMux.RUnlock()
c.logger.Debug("User cache miss", "user_name", user_name)
c.logger.Debug("User cache miss", "user_name", userName)
}
// If not found in cache, fetch user infos from API
githubUser, _, err := c.client.Users.Get(context.Background(), user_name)
githubUser, _, err := c.client.Users.Get(context.Background(), userName)
if err != nil {
return nil, fmt.Errorf("failed to fetch user with name %v: %v", user_name, err)
return nil, fmt.Errorf("failed to fetch user with name %v: %v", userName, err)
}
newUser := User{
ID: *githubUser.ID,