<commit_before>/**
 * publishingWin function.
 *
 * Site Kit by Google, Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * WordPress dependencies
 */
import { __ } from '@wordpress/i18n';

/**
 * Internal dependencies
 */
import { extractSearchConsoleDashboardData } from '../../modules/search-console/dashboard/util';
import { readableLargeNumber, getModulesData } from '../../util';

const publishingWin = ( data, id ) => {
	const showNotification = 5 === parseInt( global._googlesitekitLegacyData.admin.newSitePosts, 10 );

	if ( ! showNotification ) {
		return false;
	}

	let message = __( 'That’s out of this world.', 'google-site-kit' );
	let dataBlocks = [];

	const modulesData = getModulesData();
	if ( modulesData[ 'search-console' ] && modulesData[ 'search-console' ].active && data ) {
		const processedData = extractSearchConsoleDashboardData( data );

		const {
			totalClicks,
			totalImpressions,
			averageCTR,
		} = processedData;

		dataBlocks = [
			{
				title: __( 'Total Impressions', 'google-site-kit' ),
				datapoint: readableLargeNumber( totalImpressions ),
				datapointUnit: '',
			},
			{
				title: __( 'Total Clicks', 'google-site-kit' ),
				datapoint: readableLargeNumber( totalClicks ),
				datapointUnit: '',
			},
			{
				title: __( 'Average CTR', 'google-site-kit' ),
				datapoint: averageCTR,
				datapointUnit: '%',
			},
		];

		message = __( 'That’s out of this world. Here are the combined stats for your posts', 'google-site-kit' );<commit_msg>Fix publishing-win to display numbers correctly.<commit_after>/**
 * publishingWin function.
 *
 * Site Kit by Google, Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * WordPress dependencies
 */
import { __ } from '@wordpress/i18n';

/**
 * Internal dependencies
 */
import { extractSearchConsoleDashboardData } from '../../modules/search-console/dashboard/util';
import { getModulesData } from '../../util';

const publishingWin = ( data, id ) => {
	const showNotification = 5 === parseInt( global._googlesitekitLegacyData.admin.newSitePosts, 10 );

	if ( ! showNotification ) {
		return false;
	}

	let message = __( 'That’s out of this world.', 'google-site-kit' );
	let dataBlocks = [];

	const modulesData = getModulesData();
	if ( modulesData[ 'search-console' ] && modulesData[ 'search-console' ].active && data ) {
		const processedData = extractSearchConsoleDashboardData( data );

		const {
			totalClicks,
			totalImpressions,
			averageCTR,
		} = processedData;

		dataBlocks = [
			{
				title: __( 'Total Impressions', 'google-site-kit' ),
				datapoint: totalImpressions,
				datapointUnit: '',
			},
			{
				title: __( 'Total Clicks', 'google-site-kit' ),
				datapoint: totalClicks,
				datapointUnit: '',
			},
			{
				title: __( 'Average CTR', 'google-site-kit' ),
				datapoint: averageCTR,
				datapointUnit: '%',
			},
		];

		message = __( 'That’s out of this world. Here are the combined stats for your posts', 'google-site-kit' );
{'fraction_non_alphanumeric': 0.12345373577436912, 'fraction_numerical': 0.006432459178624443, 'mean_word_length': 3.5891032917139616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1366423', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1175, 'n_words': 376}