Repository: chef/automate
Pull request #8427 (2024-04-18 09:27:57)

Adding license audit date as last 30 days
### :nut_and_bolt: Description: What code changed, and why?

Changing the days of license audit data to be 30 days. Now it will send all the unique nodes for last 30 days.
<!-- /!\ Please ensure that you are NOT disclosing any customer information without their consent /!\ -->

### :chains: Related Resources
https://chefio.atlassian.net/browse/CHEF-11615

### :+1: Definition of Done

### :athletic_shoe: How to Build and Test the Change

```
rebuild components/compliance-service/
rebuild components/config-mgmt-service/
rebuild components/license-control-service
```

### :white_check_mark: Checklist

**All PRs** must tick these:

- [ ] I have read the [CONTRIBUTING document](https://github.com/chef/automate/blob/master/CONTRIBUTING.md).
- [ ] All commits signed-off for the [Developer Certification of Origin](https://github.com/chef/chef/blob/master/CONTRIBUTING.md#developer-certification-of-origin-dco).

With occasional exceptions, all PRs **from Progress employees** must tick these:

- [ ] Is the code clear? *(complicated code or lots of comments--subdivide and use well-named methods, meaningful variable names, etc.)*
- [ ] Consistency checked? *(user notifications, user prompts, visual patterns, code patterns, variable names)*
- [ ] Repeated code blocks eliminated? *(adapt and reuse existing components, blocks, functions, etc.)*
- [ ] Spelling, grammar, typos checked? *(at a minimum use `make spell` in any component directory)*
- [ ] Code well-formatted? *(indents, line breaks, etc. improve rather than hinder readability)*

All PRs **from Progress employees** should tick these if appropriate:

- [ ] Tests added/updated? (all new code needs new tests)
- [ ] Docs added/updated? (all customer-facing changes)

*Please add a note next to any checkbox above if you are NOT ticking it.*

### :camera: Screenshots, if applicable
[CHEF-11615.mov](https://progresssoftware.sharepoint.com/:v:/s/ChefCoreC/EcTZJYOcNi5Eqqnvm0_m-u0B7_y9CI9_-Qt6UZ5vqNAdwQ?e=5czWkM&isSPOFile=1)

netlify[bot]: ### <span aria-hidden="true">👷</span> Deploy Preview for *chef-automate* processing.


|  Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 693842ff7ac9203681f5f1e2beb6d0ae312dcdce |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/sites/chef-automate/deploys/6620e7a0946c310008fec1d8 |
sonarqube-for-infrastructure-prod[bot]: **SonarQube Quality Gate**

[![Quality Gate passed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427)

[![Bug](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/common/bug-16px.png 'Bug')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&resolved=false&types=BUG) [![A](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/RatingBadge/A-16px.png 'A')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&resolved=false&types=BUG) [0 Bugs](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&resolved=false&types=BUG)  
[![Vulnerability](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/common/vulnerability-16px.png 'Vulnerability')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&resolved=false&types=VULNERABILITY) [![A](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/RatingBadge/A-16px.png 'A')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&resolved=false&types=VULNERABILITY)  
[![Security Hotspot](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/common/security_hotspot-16px.png 'Security Hotspot')](https://sonar.progress.com/security_hotspots?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) [![A](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/RatingBadge/A-16px.png 'A')](https://sonar.progress.com/security_hotspots?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) [0 Security Hotspots](https://sonar.progress.com/security_hotspots?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427)  
[![Code Smell](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/common/code_smell-16px.png 'Code Smell')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&resolved=false&types=CODE_SMELL) [![A](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/RatingBadge/A-16px.png 'A')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&resolved=false&types=CODE_SMELL)

[![70.0%](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/CoverageChart/60-16px.png '70.0%')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_coverage&view=list) [70.0% Coverage](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_coverage&view=list)  
[![0.0%](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/Duplications/3-16px.png '0.0%')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_duplicated_lines_density&view=list)


sonarqube-for-infrastructure-prod[bot]: **SonarQube Quality Gate**

[![Quality Gate failed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427)

[![Failed condition](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/FailedConditionIcon-16px.png 'Failed condition')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) [![22.6%](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/CoverageChart/0-16px.png '22.6%')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) 22.6% Coverage on New Code (is less than 80%)  
[![Failed condition](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/FailedConditionIcon-16px.png 'Failed condition')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) [![50.0%](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/Duplications/20plus-16px.png '50.0%')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) 50.0% Duplicated Lines (%) on New Code (is greater than 3%)  

[See analysis details on SonarQube](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427)


sonarqube-for-infrastructure-prod[bot]: **SonarQube Quality Gate**

[![Quality Gate failed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427)

[![Failed condition](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/FailedConditionIcon-16px.png 'Failed condition')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) [![26.5%](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/CoverageChart/25-16px.png '26.5%')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) 26.5% Coverage on New Code (is less than 80%)  
[![Failed condition](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/FailedConditionIcon-16px.png 'Failed condition')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) [![46.2%](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v97/checks/Duplications/20plus-16px.png '46.2%')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) 46.15% Duplicated Lines (%) on New Code (is greater than 3%)  

[See analysis details on SonarQube](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427)


sonarqube-for-infrastructure-prod[bot]: ## [![Quality Gate failed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) **Quality Gate failed**  
Failed conditions  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_coverage&view=list) [20.7% Coverage on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_coverage&view=list) (required ≥ 80%)  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_duplicated_lines_density&view=list) [52.9% Duplication on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_duplicated_lines_density&view=list) (required ≤ 3%)  
  
[See analysis details on SonarQube](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427)


sonarqube-for-infrastructure-prod[bot]: ## [![Quality Gate failed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) **Quality Gate failed**  
Failed conditions  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_coverage&view=list) [19.4% Coverage on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_coverage&view=list) (required ≥ 80%)  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_duplicated_lines_density&view=list) [55.6% Duplication on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_duplicated_lines_density&view=list) (required ≤ 3%)  
  
[See analysis details on SonarQube](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427)


sonarqube-for-infrastructure-prod[bot]: ## [![Quality Gate failed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427) **Quality Gate failed**  
Failed conditions  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_coverage&view=list) [19.4% Coverage on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_coverage&view=list) (required ≥ 80%)  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_duplicated_lines_density&view=list) [55.6% Duplication on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427&metric=new_duplicated_lines_density&view=list) (required ≤ 3%)  
  
[See analysis details on SonarQube](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8427)



Patch:
diff --git a/VERSION b/VERSION
index 1c7335555..85ef632c7 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-4.12.121
\ No newline at end of file
+4.12.122
\ No newline at end of file
diff --git a/components/compliance-service/api/stats/server/server.go b/components/compliance-service/api/stats/server/server.go
index cf3eedceb..e17161be1 100644
--- a/components/compliance-service/api/stats/server/server.go
+++ b/components/compliance-service/api/stats/server/server.go
@@ -160,7 +160,7 @@ func (srv *Server) ReadFailures(ctx context.Context, in *stats.Query) (*stats.Fa
 	return failures, nil
 }
 
-//UpdateTelemetryReported Updates the last compliance telemetry reported date in postgres after the telemetry data is sent
+// UpdateTelemetryReported Updates the last compliance telemetry reported date in postgres after the telemetry data is sent
 func (srv *Server) UpdateTelemetryReported(ctx context.Context, in *stats.UpdateTelemetryReportedRequest) (*stats.UpdateTelemetryReportedResponse, error) {
 	err := srv.pg.UpdateLastTelemetryReported(ctx, in)
 	if err != nil {
@@ -169,7 +169,7 @@ func (srv *Server) UpdateTelemetryReported(ctx context.Context, in *stats.Update
 	return &stats.UpdateTelemetryReportedResponse{}, nil
 }
 
-//GetNodesUsageCount returns the count of unique nodes with lastRun in a given time.
+// GetNodesUsageCount returns the count of unique nodes with lastRun in a given time.
 func (srv *Server) GetNodesUsageCount(ctx context.Context, in *stats.GetNodesUsageCountRequest) (*stats.GetNodesUsageCountResponse, error) {
 	var count int64
 	// Get last telemetry reported date from postgres
@@ -179,12 +179,14 @@ func (srv *Server) GetNodesUsageCount(ctx context.Context, in *stats.GetNodesUsa
 	}
 	var daysSinceLastPost int
 	if telemetry.LastTelemetryReportedAt.IsZero() {
-		daysSinceLastPost = 15
+		daysSinceLastPost = 30
 	} else {
 		daysSinceLastPost = utils.DaysBetween(telemetry.LastTelemetryReportedAt, time.Now())
 	}
 	if daysSinceLastPost > 0 {
-		count, err = srv.es.GetUniqueNodesCount(int64(daysSinceLastPost), telemetry.LastTelemetryReportedAt)
+		//CHEF-11615 Making the duration as 30 days
+		duration := 30
+		count, err = srv.es.GetUniqueNodesCount(int64(duration), telemetry.LastTelemetryReportedAt)
 		if err != nil {
 			return nil, err
 		}
diff --git a/components/compliance-service/reporting/relaxting/stats.go b/components/compliance-service/reporting/relaxting/stats.go
index 802f31544..68a809da0 100644
--- a/components/compliance-service/reporting/relaxting/stats.go
+++ b/components/compliance-service/reporting/relaxting/stats.go
@@ -4,9 +4,10 @@ import (
 	"context"
 	"encoding/json"
 	"fmt"
-	"github.com/chef/automate/api/interservice/compliance/ingest/events/inspec"
 	"time"
 
+	"github.com/chef/automate/api/interservice/compliance/ingest/events/inspec"
+
 	elastic "github.com/olivere/elastic/v7"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
@@ -16,7 +17,7 @@ import (
 	"github.com/chef/automate/components/compliance-service/ingest/ingestic/mappings"
 )
 
-//GetStatsSummary - Report #16
+// GetStatsSummary - Report #16
 func (backend ES2Backend) GetStatsSummary(filters map[string][]string) (*stats.ReportSummary, error) {
 	myName := "GetStatsSummary"
 	// Only end_time matters for this call
@@ -67,7 +68,7 @@ func (backend ES2Backend) GetStatsSummary(filters map[string][]string) (*stats.R
 	return depth.getStatsSummaryResult(searchResult), nil
 }
 
-//GetStatsSummaryNodes - Gets summary stats, node centric, aggregate data for the given set of filters
+// GetStatsSummaryNodes - Gets summary stats, node centric, aggregate data for the given set of filters
 func (backend ES2Backend) GetStatsSummaryNodes(filters map[string][]string) (*stats.NodeSummary, error) {
 	myName := "GetStatsSummaryNodes"
 	latestOnly := FetchLatestDataOrNot(filters)
@@ -119,7 +120,7 @@ func (backend ES2Backend) GetStatsSummaryNodes(filters map[string][]string) (*st
 	return depth.getStatsSummaryNodesResult(searchResult), nil
 }
 
-//GetStatsSummaryControlsRange - Gets summary stats, control centric, aggregate data for the given set of filters with date range
+// GetStatsSummaryControlsRange - Gets summary stats, control centric, aggregate data for the given set of filters with date range
 func (backend ES2Backend) GetStatsSummaryControlsRange(filters map[string][]string) (*stats.ControlsSummary, error) {
 	myName := "GetStatsSummaryControlsRange"
 
@@ -168,7 +169,7 @@ func (backend ES2Backend) GetStatsSummaryControlsRange(filters map[string][]stri
 	return backend.getStatsSummaryControlsResult(searchResult), nil
 }
 
-//GetStatsSummaryControls - Gets summary stats, control centric, aggregate data for the given set of filters
+// GetStatsSummaryControls - Gets summary stats, control centric, aggregate data for the given set of filters
 func (backend ES2Backend) GetStatsSummaryControls(filters map[string][]string) (*stats.ControlsSummary, error) {
 	myName := "GetStatsSummaryControls"
 
@@ -231,7 +232,7 @@ func (backend ES2Backend) GetStatsSummaryControls(filters map[string][]string) (
 	return depth.getStatsSummaryControlsResult(searchResult), nil
 }
 
-//GetStatsFailures - Gets top failures, aggregate data for the given set of filters
+// GetStatsFailures - Gets top failures, aggregate data for the given set of filters
 func (backend ES2Backend) GetStatsFailures(reportTypes []string, size int, filters map[string][]string) (*stats.Failures, error) {
 	myName := "GetStatsFailures"
 	var failures *stats.Failures
@@ -294,8 +295,8 @@ func (backend ES2Backend) GetStatsFailures(reportTypes []string, size int, filte
 	return depth.getStatsTopFailuresResult(searchResult, reportTypes)
 }
 
-//GetProfileListWithAggregatedComplianceSummaries - Report #6
-//todo - Where in A2 UI is this being called? It now works with deep filtering but not sure if we need it.
+// GetProfileListWithAggregatedComplianceSummaries - Report #6
+// todo - Where in A2 UI is this being called? It now works with deep filtering but not sure if we need it.
 func (backend ES2Backend) GetProfileListWithAggregatedComplianceSummaries(
 	filters map[string][]string, size int32) ([]*stats.ProfileList, error) {
 	myName := "GetProfileListWithAggregatedComplianceSummaries"
@@ -338,7 +339,7 @@ func (backend ES2Backend) GetProfileListWithAggregatedComplianceSummaries(
 	return depth.getProfileListWithAggregatedComplianceSummariesResults(searchResult, filters), nil
 }
 
-//GetControlListStatsByProfileID returns the control list for a given profile or profile and a child control
+// GetControlListStatsByProfileID returns the control list for a given profile or profile and a child control
 // the data retrieved from this appears at the bottom of the a2 page when you select a profile from list
 func (backend ES2Backend) GetControlListStatsByProfileID(profileID string, from int, size int,
 	filters map[string][]string, sortField string, sortAsc bool) ([]*stats.ControlStats, error) {
@@ -391,7 +392,7 @@ func (backend ES2Backend) GetControlListStatsByProfileID(profileID string, from
 	return depth.getControlListStatsByProfileIdResults(&backend, searchResult, profileID)
 }
 
-//GetUniqueNodesCount: Get the unique nodes count based on the lastTelemetryReportedAt
+// GetUniqueNodesCount: Get the unique nodes count based on the lastTelemetryReportedAt
 func (backend ES2Backend) GetUniqueNodesCount(daysSinceLastPost int64, lastTelemetryReportedAt time.Time) (int64, error) {
 	client, err := backend.ES2Client()
 	if err != nil {
@@ -400,21 +401,21 @@ func (backend ES2Backend) GetUniqueNodesCount(daysSinceLastPost int64, lastTelem
 	}
 
 	var rangeQueryThreshold *elastic.RangeQuery
-	t := time.Now().AddDate(0, 0, -1)
-	yesterdayEODTimeStamp := time.Date(t.Year(), t.Month(), t.Day(), 23, 59, 59, t.Nanosecond(), t.Location())
+	t := time.Now()
+	startDayTimeStamp := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, t.Nanosecond(), t.Location())
 	lastTelemetryReportedDate := lastTelemetryReportedAt.Format("2006-01-02")
 
 	// if daysSinceLastPost >= three months then take the unique nodes count from last three months
-	// and if daysSinceLastPost > 15 and < three months then take unique nodes count from lastTelemetryReportedDate to yesterday EOD
-	// else take the unique nodes count from last 15 days
+	// and if daysSinceLastPost > 30 and < three months then take unique nodes count from lastTelemetryReportedDate to current time
+	// else take the unique nodes count from last 30 days
 	if daysSinceLastPost >= 90 {
-		startTimeStamp := yesterdayEODTimeStamp.AddDate(0, 0, -91)
-		rangeQueryThreshold = elastic.NewRangeQuery("last_run").From(startTimeStamp).To(yesterdayEODTimeStamp)
-	} else if daysSinceLastPost > 15 {
-		rangeQueryThreshold = elastic.NewRangeQuery("last_run").From(lastTelemetryReportedDate).To(yesterdayEODTimeStamp)
+		startTimeStamp := startDayTimeStamp.AddDate(0, 0, -91)
+		rangeQueryThreshold = elastic.NewRangeQuery("last_run").From(startTimeStamp).To(time.Now())
+	} else if daysSinceLastPost > 30 {
+		rangeQueryThreshold = elastic.NewRangeQuery("last_run").From(lastTelemetryReportedDate).To(time.Now())
 	} else {
-		startTimeStamp := yesterdayEODTimeStamp.AddDate(0, 0, -16)
-		rangeQueryThreshold = elastic.NewRangeQuery("last_run").From(startTimeStamp).To(yesterdayEODTimeStamp)
+		startTimeStamp := startDayTimeStamp.AddDate(0, 0, -31)
+		rangeQueryThreshold = elastic.NewRangeQuery("last_run").From(startTimeStamp).To(time.Now())
 	}
 	boolQuery := elastic.NewBoolQuery().
 		Must(rangeQueryThreshold)
@@ -447,7 +448,7 @@ func (backend ES2Backend) getStatsSummaryControlsAggs() map[string]elastic.Aggre
 	return aggs
 }
 
-//getStatsSummaryControlsResult get the aggregations result for the control summary query
+// getStatsSummaryControlsResult get the aggregations result for the control summary query
 func (backend ES2Backend) getStatsSummaryControlsResult(aggRoot *elastic.SearchResult) *stats.ControlsSummary {
 	summary := &stats.ControlsSummary{}
 
diff --git a/components/config-mgmt-service/backend/elastic/telemetry.go b/components/config-mgmt-service/backend/elastic/telemetry.go
index 4afa9e386..015f25477 100644
--- a/components/config-mgmt-service/backend/elastic/telemetry.go
+++ b/components/config-mgmt-service/backend/elastic/telemetry.go
@@ -7,25 +7,25 @@ import (
 	elastic "github.com/olivere/elastic/v7"
 )
 
-//GetUniqueNodesCount: Get the unique nodes count based on the lastTelemetryReportedAt
+// GetUniqueNodesCount: Get the unique nodes count based on the lastTelemetryReportedAt
 func (es Backend) GetUniqueNodesCount(daysSinceLastPost int64, lastTelemetryReportedAt time.Time) (int64, error) {
 
 	var rangeQueryThreshold *elastic.RangeQuery
-	t := time.Now().AddDate(0, 0, -1)
-	yesterdayEODTimeStamp := time.Date(t.Year(), t.Month(), t.Day(), 23, 59, 59, t.Nanosecond(), t.Location())
+	t := time.Now()
+	startDayTimeStamp := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, t.Nanosecond(), t.Location())
 	lastTelemetryReportedDate := lastTelemetryReportedAt.Format("2006-01-02")
 
 	// if daysSinceLastPost >= three months then take the unique nodes count from last three months
-	// and if daysSinceLastPost > 15 and < three months then take unique nodes count from lastTelemetryReportedDate to yesterday EOD
-	// else take the unique nodes count from last 15 days
+	// and if daysSinceLastPost > 30 and < three months then take unique nodes count from lastTelemetryReportedDate to current time
+	// else take the unique nodes count from last 30 days
 	if daysSinceLastPost >= 90 {
-		startTimeStamp := yesterdayEODTimeStamp.AddDate(0, 0, -91)
-		rangeQueryThreshold = elastic.NewRangeQuery("last_run").From(startTimeStamp).To(yesterdayEODTimeStamp)
-	} else if daysSinceLastPost > 15 {
-		rangeQueryThreshold = elastic.NewRangeQuery("last_run").From(lastTelemetryReportedDate).To(yesterdayEODTimeStamp)
+		startTimeStamp := startDayTimeStamp.AddDate(0, 0, -91)
+		rangeQueryThreshold = elastic.NewRangeQuery("last_run").From(startTimeStamp).To(time.Now())
+	} else if daysSinceLastPost > 30 {
+		rangeQueryThreshold = elastic.NewRangeQuery("last_run").From(lastTelemetryReportedDate).To(time.Now())
 	} else {
-		startTimeStamp := yesterdayEODTimeStamp.AddDate(0, 0, -16)
-		rangeQueryThreshold = elastic.NewRangeQuery("last_run").From(startTimeStamp).To(yesterdayEODTimeStamp)
+		startTimeStamp := startDayTimeStamp.AddDate(0, 0, -31)
+		rangeQueryThreshold = elastic.NewRangeQuery("last_run").From(startTimeStamp).To(time.Now())
 	}
 	boolQuery := elastic.NewBoolQuery().
 		Must(rangeQueryThreshold)
diff --git a/components/config-mgmt-service/grpcserver/telemetry.go b/components/config-mgmt-service/grpcserver/telemetry.go
index ec8d48bed..b632194d7 100644
--- a/components/config-mgmt-service/grpcserver/telemetry.go
+++ b/components/config-mgmt-service/grpcserver/telemetry.go
@@ -10,7 +10,7 @@ import (
 	"google.golang.org/grpc/status"
 )
 
-//UpdateTelemetryReported Update the last client run telemetry reported date in postgres
+// UpdateTelemetryReported Update the last client run telemetry reported date in postgres
 func (s *CfgMgmtServer) UpdateTelemetryReported(ctx context.Context, req *request.UpdateTelemetryReportedRequest) (*response.UpdateTelemetryReportedResponse, error) {
 	if req == nil {
 		return nil, status.Error(codes.InvalidArgument, "empty request")
@@ -24,7 +24,7 @@ func (s *CfgMgmtServer) UpdateTelemetryReported(ctx context.Context, req *reques
 	return &response.UpdateTelemetryReportedResponse{}, nil
 }
 
-//GetNodesUsageCount returns the count of unique nodes with lastRun in a given time.
+// GetNodesUsageCount returns the count of unique nodes with lastRun in a given time.
 func (s *CfgMgmtServer) GetNodesUsageCount(ctx context.Context, req *request.GetNodesUsageCountRequest) (*response.GetNodesUsageCountResponse, error) {
 	var count int64
 	// Get last telemetry reported date from postgres
@@ -34,12 +34,13 @@ func (s *CfgMgmtServer) GetNodesUsageCount(ctx context.Context, req *request.Get
 	}
 	var daysSinceLastPost int
 	if telemetry.LastTelemetryReportedAt.IsZero() {
-		daysSinceLastPost = 15
+		daysSinceLastPost = 30
 	} else {
 		daysSinceLastPost = DaysBetween(telemetry.LastTelemetryReportedAt, time.Now())
 	}
 	if daysSinceLastPost > 0 {
-		count, err = s.client.GetUniqueNodesCount(int64(daysSinceLastPost), telemetry.LastTelemetryReportedAt)
+		duration := 30
+		count, err = s.client.GetUniqueNodesCount(int64(duration), telemetry.LastTelemetryReportedAt)
 		if err != nil {
 			return nil, err
 		}
diff --git a/components/license-control-service/licenseaudit/licenseauditworkflow.go b/components/license-control-service/licenseaudit/licenseauditworkflow.go
index 7b368690b..d5ba381df 100644
--- a/components/license-control-service/licenseaudit/licenseauditworkflow.go
+++ b/components/license-control-service/licenseaudit/licenseauditworkflow.go
@@ -218,12 +218,16 @@ func executeCommandforAudit(executeCommand ExecuteCommand, command string) (stri
 
 // getAppendedCommand gets the appended command with date
 func getAppendedCommand(commandToExecute string, url string) string {
-	yesterdayDate := time.Now().AddDate(0, 0, -1).UTC().Format("2006-01-02")
+	//Taking the date time as last 30 days
+	startDate := time.Now().AddDate(0, 0, -31).Format("2006-01-02")
+	//StartDateTime start of the day timestamp as 00:00:00
+
+	endDate := time.Now().UTC().Format("2006-01-02")
 	if url == "" {
-		return fmt.Sprintf(commandToExecute, yesterdayDate, yesterdayDate, OutputFileName)
+		return fmt.Sprintf(commandToExecute, startDate, endDate, OutputFileName)
 	}
 	commandToExecute = commandToExecute + " -u %s"
-	return fmt.Sprintf(commandToExecute, yesterdayDate, yesterdayDate, OutputFileName, url)
+	return fmt.Sprintf(commandToExecute, startDate, endDate, OutputFileName, url)
 }
 
 func getWorkflowParametersAndEnqueTask(w cereal.WorkflowInstance) (AuditWorkflowParameters, error) {


Test patch:
diff --git a/components/license-control-service/licenseaudit/licenseauditworkflow_test.go b/components/license-control-service/licenseaudit/licenseauditworkflow_test.go
index c6f2ea9eb..335b1e0f6 100644
--- a/components/license-control-service/licenseaudit/licenseauditworkflow_test.go
+++ b/components/license-control-service/licenseaudit/licenseauditworkflow_test.go
@@ -345,16 +345,18 @@ func Test_getAppendedCommand(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			dateToBeAppended := time.Now().AddDate(0, 0, -1).UTC().Format("2006-01-02")
+			startDate := time.Now().AddDate(0, 0, -31).Format("2006-01-02")
+			endDate := time.Now().UTC().Format("2006-01-02")
 
 			got := getAppendedCommand(tt.command, tt.url)
 
 			if tt.url == "" {
-				tt.want = fmt.Sprintf(tt.command, dateToBeAppended, dateToBeAppended, OutputFileName)
+				tt.want = fmt.Sprintf(tt.command, startDate, endDate, OutputFileName)
 			} else {
 				tt.command = tt.command + " -u %s"
-				tt.want = fmt.Sprintf(tt.command, dateToBeAppended, dateToBeAppended, OutputFileName, tt.url)
+				tt.want = fmt.Sprintf(tt.command, startDate, endDate, OutputFileName, tt.url)
 			}
+
 			assert.Equal(t, tt.want, got)
 		})
 	}