Skip to content

Commit

Permalink
Merge pull request #672 from guardian/tf-remove-analytics
Browse files Browse the repository at this point in the history
Remove analytics button from epic tool
  • Loading branch information
tomrf1 authored Jan 20, 2025
2 parents 64f99f8 + 267588d commit 911f212
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 309 deletions.
46 changes: 0 additions & 46 deletions app/controllers/AnalyticsController.scala

This file was deleted.

34 changes: 0 additions & 34 deletions app/models/Analytics.scala

This file was deleted.

57 changes: 0 additions & 57 deletions app/services/Athena.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package services

import com.typesafe.scalalogging.StrictLogging
import io.circe.{Decoder, Encoder}
import models.GroupedVariantViews.VariantName
import models.{Channel, GroupedVariantViews, VariantViews}
import services.AthenaError.{AthenaError, AthenaQueryFailed, AthenaResultPending}
import zio.blocking.effectBlocking
import zio.{ZEnv, ZIO}
Expand Down Expand Up @@ -126,36 +124,6 @@ class Athena() extends StrictLogging {
.map(_.queryExecutionId())
}

private def startVariantViewsQuery(from: String, to: String, channel: String, testName: String): ZIO[ZEnv, AthenaError, QueryExecutionId] = {
logger.info(s"Querying athena")

val query =
s"""
|SELECT date_hour, ab.variant, COUNT(*) AS views
|FROM acquisition.epic_views_prod, UNNEST(abtests) t(ab)
|WHERE date_hour >= TIMESTAMP '$from' AND date_hour < TIMESTAMP '$to'
|AND ab.name = ?
|GROUP BY 1,2 ORDER BY 1,2
"""

val request = StartQueryExecutionRequest
.builder()
.queryString(
query.stripMargin
)
.executionParameters(testName)
.queryExecutionContext(queryExecutionContext)
.resultConfiguration(resultConfiguration)
.build()

effectBlocking(client.startQueryExecution(request))
.mapError(err => {
logger.error(s"Query failed with: ${err.getMessage}")
AthenaQueryFailed(err)
})
.map(_.queryExecutionId())
}

// Repeatedly checks the status of the query execution until it either succeeds or fails
private def pollQueryResult(queryExecutionId: String): ZIO[ZEnv, AthenaError, QueryExecutionId] =
effectBlocking {
Expand Down Expand Up @@ -212,29 +180,4 @@ class Athena() extends StrictLogging {
})
.tapError(error => ZIO.succeed(logger.error(s"Athena error: ${error.getMessage}")))
.tap(result => ZIO.succeed(logger.info(s"Athena result: ${result.length}")))

def getVariantViews(from: String, to: String, channel: String, testName: String): ZIO[ZEnv, Throwable, List[GroupedVariantViews]] = {
startVariantViewsQuery(from, to, channel, testName)
.flatMap(pollQueryResult)
.flatMap(getQueryResult)
.map(rows => {
rows
.flatMap(row => {
val variantViews = VariantViews.parse(row)
if (variantViews.isEmpty) {
logger.error(s"Failed to parse row from athena: $row")
}
variantViews
})
.groupBy(variantViews => variantViews.dateHour)
.map { case (dateHour, variantViewsList) => dateHour -> {
val viewCounts = variantViewsList.foldLeft(Map.empty[VariantName,Int])((acc, variantViews) => acc + (variantViews.name -> variantViews.views))
GroupedVariantViews(dateHour, viewCounts)
}}
.values.toList
.sortBy(_.dateHour)
})
.tapError(error => ZIO.succeed(logger.error(s"Athena error: ${error.getMessage}")))
.tap(result => ZIO.succeed(logger.info(s"Athena result: $result")))
}
}
1 change: 0 additions & 1 deletion app/wiring/AppComponents.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class AppComponents(context: Context, stage: String) extends BuiltInComponentsFr
new AppsMeteringSwitchesController(authAction, controllerComponents, stage, runtime),
new DefaultPromosController(authAction,controllerComponents, stage, runtime),
new SuperModeController(authAction, controllerComponents, stage, runtime, dynamoSuperModeService, athena),
new AnalyticsController(authAction, controllerComponents, stage, runtime, athena),
new BanditDataController(authAction, controllerComponents, stage, runtime, dynamoBanditData),
assets
)
Expand Down
1 change: 0 additions & 1 deletion conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ GET /frontend/super-mode controllers.SuperModeCont
GET /frontend/epic-article-data controllers.SuperModeController.getArticleData()

# ----- analytics ----- #
GET /frontend/analytics/:channel/:testName controllers.AnalyticsController.getDataForVariants(channel: String, testName: String)
GET /frontend/bandit/:channel/:testName controllers.BanditDataController.getDataForTest(channel: String, testName: String)

# Map static resources from the /public folder to the /assets URL path
Expand Down
161 changes: 0 additions & 161 deletions public/src/components/channelManagement/AnalyticsButton.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { useStyles } from '../helpers/testEditorStyles';
import { EpicTestPreviewButton } from './testPreview';
import { ValidatedTestEditor, ValidatedTestEditorProps } from '../validatedTestEditor';
import { TestEditorProps } from '../testsForm';
import { AnalyticsButton } from '../AnalyticsButton';
import { TestMethodologyEditor } from '../TestMethodologyEditor';

const copyHasTemplate = (test: EpicTest, template: string): boolean =>
Expand Down Expand Up @@ -240,9 +239,6 @@ export const getEpicTestEditor = (
</Typography>
<div className={classes.variantsHeaderButtonsContainer}>
<EpicTestPreviewButton test={test} moduleName={epicEditorConfig.moduleName} />
{epicEditorConfig.allowAnalyticsButton && (
<AnalyticsButton test={test} channel={'Epic'} />
)}
</div>
</div>
<div>
Expand Down
5 changes: 0 additions & 5 deletions public/src/components/channelManagement/helpers/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export interface EpicEditorConfig {
requireVariantHeader: boolean;
moduleName: EpicModuleName;
allowNewsletterSignup: boolean;
allowAnalyticsButton: boolean;
}

export const ARTICLE_EPIC_CONFIG: EpicEditorConfig = {
Expand Down Expand Up @@ -113,7 +112,6 @@ export const ARTICLE_EPIC_CONFIG: EpicEditorConfig = {
moduleName: 'ContributionsEpic',
platform: 'DOTCOM',
allowNewsletterSignup: false,
allowAnalyticsButton: true,
};

export const LIVEBLOG_EPIC_CONFIG: EpicEditorConfig = {
Expand Down Expand Up @@ -143,7 +141,6 @@ export const LIVEBLOG_EPIC_CONFIG: EpicEditorConfig = {
moduleName: 'ContributionsLiveblogEpic',
platform: 'DOTCOM',
allowNewsletterSignup: true,
allowAnalyticsButton: false,
};

export const APPLE_NEWS_EPIC_CONFIG: EpicEditorConfig = {
Expand Down Expand Up @@ -174,7 +171,6 @@ export const APPLE_NEWS_EPIC_CONFIG: EpicEditorConfig = {
moduleName: 'ContributionsEpic',
platform: 'APPLE_NEWS',
allowNewsletterSignup: false,
allowAnalyticsButton: false,
};

export const AMP_EPIC_CONFIG: EpicEditorConfig = {
Expand Down Expand Up @@ -204,7 +200,6 @@ export const AMP_EPIC_CONFIG: EpicEditorConfig = {
moduleName: 'ContributionsEpic',
platform: 'AMP',
allowNewsletterSignup: false,
allowAnalyticsButton: false,
};

export interface LockStatus {
Expand Down

0 comments on commit 911f212

Please sign in to comment.