Skip to content

Adding Changes to add Accounttype only for specific models#167

Open
gravi21 wants to merge 3 commits into
developfrom
feature/accounttype
Open

Adding Changes to add Accounttype only for specific models#167
gravi21 wants to merge 3 commits into
developfrom
feature/accounttype

Conversation

@gravi21
Copy link
Copy Markdown
Contributor

@gravi21 gravi21 commented Jun 2, 2026

No description provided.

@github-advanced-security
Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@gravi21 gravi21 requested a review from sanwar96 June 2, 2026 17:00
log.WithFields(fields).Debugf("AddEstbFirmwareContext AcntId='%s' already present,fetching AccntPrds directly from ada", contextMap[common.ACCOUNT_ID])
log.WithFields(fields).Debugf("AddEstbFirmwareContext AcntId='%s' received from grpsvc,now fetching AccntPrds", contextMap[common.ACCOUNT_ID])

if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) {
Copy link
Copy Markdown
Contributor

@RahulRengeshOfficial RahulRengeshOfficial Jun 3, 2026

Choose a reason for hiding this comment

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

Hello @gravi21
I see the same AccountTypeModelSet.IsEmpty() || AccountTypeModelSet.Contains(...) condition being checked at both line 267 and line 277. Since contextMap[common.MODEL] doesn't change between these two points, the inner check at line 277 appears to be redundant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@RahulRengeshOfficial in line 277 case is for when we already have accountId in the request from device and in line 267 is for unknown accountId case.
All these is for workround until we get accounttype in /ada keyspace


if accountType, ok := accountProducts["AccountType"]; ok && accountType != "" {
contextMap[common.ACCOUNT_TYPE] = accountType
if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello @gravi21
I see the same AccountTypeModelSet.IsEmpty() || AccountTypeModelSet.Contains(...) condition being checked before, Since contextMap[common.MODEL] doesn't change between these two points, the inner check appears to be redundant.

Copy link
Copy Markdown
Contributor

@pt-nguyen pt-nguyen left a comment

Choose a reason for hiding this comment

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

Minor performance improvement to avoid calling IsValidMacAddress again.

log.WithFields(fields).Debugf("AddEstbFirmwareContext AcntId='%s' received from grpsvc,now fetching AccntPrds", contextMap[common.ACCOUNT_ID])

if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) {
if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@gravi21 Can we cache the value of checking if mac address is valid so that we don't to do the same check again on line 285?

validMac := util.IsValidMacAddress(contextMap[common.ESTB_MAC])
if validMac {
...

}

if xAccountId == nil && err != nil {
if util.IsValidMacAddress(contextMap[common.ECM_MAC_ADDRESS]) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need to call check again.
if validMac {

log.WithFields(fields).Debugf("AddFeatureControlContext AcntId='%s' already present", contextMap[common.ACCOUNT_ID])

if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) {
if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should cache value if mac is valid so don't have to call gain.

log.WithFields(fields).Debugf("AddLogUploaderContext AcntId='%s' already present,fetching AccntPrds directly from ada", contextMap[common.ACCOUNT_ID])

if Xc.AccountTypeModelSet.IsEmpty() || Xc.AccountTypeModelSet.Contains(strings.ToLower(contextMap[common.MODEL])) {
if util.IsValidMacAddress(contextMap[common.ESTB_MAC]) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should cache value if mac is valid so don't have to call gain.

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.

6 participants