Skip to content

Commit

Permalink
Merge pull request #10124 from google/bug/top-traffic-source-90-days-…
Browse files Browse the repository at this point in the history
…data

Update getDateRangeIndex logic.
  • Loading branch information
tofumatt authored Jan 29, 2025
2 parents 020c771 + 95f21a1 commit 6a5f491
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ import whenActive from '../../../../util/when-active';
import ConnectGA4CTATileWidget from './ConnectGA4CTATileWidget';

function getDateRangeIndex( reportRows, dateRangeSlug ) {
const dateRange = reportRows?.[ 0 ]?.dimensionValues?.find(
( dimension ) => dimension.value === dateRangeSlug
);
const dateRangeIndex =
reportRows?.[ 0 ]?.dimensionValues?.indexOf( dateRange );
for ( let rowIndex = 0; rowIndex < reportRows.length; rowIndex++ ) {
const dimensionValues = reportRows?.[ rowIndex ]?.dimensionValues;

const dimensionIndex = dimensionValues.findIndex(
( dimensionValue ) => dimensionValue.value === dateRangeSlug
);

if ( dimensionIndex !== -1 ) {
return dimensionIndex;
}
}

return dateRangeIndex;
return 0;
}

function TopTrafficSourceDrivingLeadsWidget( { Widget } ) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6a5f491

Please sign in to comment.