Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(feature-manager): tear out AggregateStats feature #2120

Merged
merged 4 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .template-env
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ FORMSG_SDK_MODE=
# APP_NAME=FormSG
# OTP_LIFE_SPAN=900000
# BOUNCE_LIFE_SPAN=86400000
# AGGREGATE_COLLECTION=

# If provided, a banner with the provided message will show up in every form.
# IS_GENERAL_MAINTENANCE=
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ services:
- CORPPASS_IDP_ID
- IS_SP_MAINTENANCE
- IS_CP_MAINTENANCE
- AGGREGATE_COLLECTION

mockpass:
build: https://github.com/opengovsg/mockpass.git
Expand Down
10 changes: 0 additions & 10 deletions docs/DEPLOYMENT_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,6 @@ If this feature is enabled, client-side error events will be piped to [sentry.io
| `SENTRY_CONFIG_URL` | Sentry.io URL for configuring the Raven SDK. |
| `CSP_REPORT_URI` | Reporting URL for Content Security Policy violdations. Can be configured to use a Sentry.io endpoint. |

#### Examples page Using Pre-Computed Results

If this feature is enabled, the submission statistics associated with forms loaded on the examples page will be fetched from the pre-computed values in the FormStatisticsTotal collection. The FormStatisticsTotal collection only exists if the [batch jobs](https://github.com/datagovsg/formsg-batch-jobs/) needed to calculate the submission statistics are run daily.

If this feature is not enabled, the submission statistics associated with forms loaded on the examples page will be calculated on the fly from the Submissions collection. This may be sub-optimal when submissions are in the millions.

| Variable | Description |
| :--------------------- | --------------------------------------------------------------------- |
| `AGGREGATE_COLLECTION` | Has to be defined (i.e. =true) if FormStats collection is to be used. |

#### SMS with Twilio

If this feature is enabled, the Mobile Number field will support form-fillers verifying their mobile numbers via a One-Time-Pin sent to their mobile phones and will also support an SMS confirmation of successful submission being sent out to their said mobile numbers. All messages are sent using [twilio](https://www.twilio.com/) messaging APIs.
Expand Down
16 changes: 0 additions & 16 deletions src/app/config/feature-manager/aggregate-stats.config.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/app/config/feature-manager/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import FeatureManager from './util/FeatureManager.class'
import aggregateStats from './aggregate-stats.config'
import captcha from './captcha.config'
import googleAnalytics from './google-analytics.config'
import { intranetFeature } from './intranet.config'
Expand All @@ -17,7 +16,6 @@ const featureManager = new FeatureManager()
featureManager.register(captcha)
featureManager.register(sentry)
featureManager.register(googleAnalytics)
featureManager.register(aggregateStats)
featureManager.register(spcpMyInfo)
featureManager.register(webhookVerifiedContent)
featureManager.register(sms)
Expand Down
6 changes: 0 additions & 6 deletions src/app/config/feature-manager/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { MyInfoMode } from '@opengovsg/myinfo-gov-client'
import { Schema } from 'convict'

export enum FeatureNames {
AggregateStats = 'aggregate-stats',
Captcha = 'captcha',
GoogleAnalytics = 'google-analytics',
Sentry = 'sentry',
Expand All @@ -13,10 +12,6 @@ export enum FeatureNames {
Intranet = 'intranet',
}

export interface IAggregateStats {
aggregateCollection: string
}

export interface ICaptcha {
captchaPrivateKey: string
captchaPublicKey: string
Expand Down Expand Up @@ -87,7 +82,6 @@ export interface IIntranet {
}

export interface IFeatureManager {
[FeatureNames.AggregateStats]: IAggregateStats
[FeatureNames.Captcha]: ICaptcha
[FeatureNames.GoogleAnalytics]: IGoogleAnalytics
[FeatureNames.Sentry]: ISentry
Expand Down
26 changes: 13 additions & 13 deletions src/app/modules/examples/__tests__/examples.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import expressHandler from 'tests/unit/backend/helpers/jest-express'
import { DatabaseError } from '../../core/core.errors'
import * as ExamplesController from '../examples.controller'
import { ResultsNotFoundError } from '../examples.errors'
import { ExamplesFactory } from '../examples.factory'
import * as ExamplesService from '../examples.service'
import { ExamplesQueryParams, SingleFormResult } from '../examples.types'

jest.mock('../examples.factory')
const MockExamplesFactory = mocked(ExamplesFactory)
jest.mock('../examples.service')
const MockExamplesService = mocked(ExamplesService)

describe('examples.controller', () => {
beforeEach(() => jest.clearAllMocks())
Expand All @@ -38,15 +38,15 @@ describe('examples.controller', () => {
forms: [],
totalNumResults: 0,
}
MockExamplesFactory.getExampleForms.mockReturnValueOnce(
MockExamplesService.getExampleForms.mockReturnValueOnce(
okAsync(mockResult),
)

// Act
await ExamplesController.handleGetExamples(MOCK_REQ, mockRes, jest.fn())

// Assert
expect(MockExamplesFactory.getExampleForms).toHaveBeenCalledWith(
expect(MockExamplesService.getExampleForms).toHaveBeenCalledWith(
MOCK_REQ_QUERY,
)
expect(mockRes.status).toBeCalledWith(200)
Expand All @@ -57,15 +57,15 @@ describe('examples.controller', () => {
// Arrange
const mockRes = expressHandler.mockResponse()
// Mock getExampleForms to return error.
MockExamplesFactory.getExampleForms.mockReturnValueOnce(
MockExamplesService.getExampleForms.mockReturnValueOnce(
errAsync(new DatabaseError()),
)

// Act
await ExamplesController.handleGetExamples(MOCK_REQ, mockRes, jest.fn())

// Assert
expect(MockExamplesFactory.getExampleForms).toHaveBeenCalledWith(
expect(MockExamplesService.getExampleForms).toHaveBeenCalledWith(
MOCK_REQ_QUERY,
)
expect(mockRes.status).toBeCalledWith(500)
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('examples.controller', () => {
title: 'mockTitle',
},
}
MockExamplesFactory.getSingleExampleForm.mockReturnValueOnce(
MockExamplesService.getSingleExampleForm.mockReturnValueOnce(
okAsync(mockResult),
)

Expand All @@ -118,7 +118,7 @@ describe('examples.controller', () => {
)

// Assert
expect(MockExamplesFactory.getSingleExampleForm).toHaveBeenCalledWith(
expect(MockExamplesService.getSingleExampleForm).toHaveBeenCalledWith(
MOCK_REQ_PARAMS.formId,
)
expect(mockRes.status).toBeCalledWith(200)
Expand All @@ -130,7 +130,7 @@ describe('examples.controller', () => {
const mockRes = expressHandler.mockResponse()
// Mock getSingleExampleForm to return not found error.
const mockErrorString = 'not found error!'
MockExamplesFactory.getSingleExampleForm.mockReturnValueOnce(
MockExamplesService.getSingleExampleForm.mockReturnValueOnce(
errAsync(new ResultsNotFoundError(mockErrorString)),
)

Expand All @@ -142,7 +142,7 @@ describe('examples.controller', () => {
)

// Assert
expect(MockExamplesFactory.getSingleExampleForm).toHaveBeenCalledWith(
expect(MockExamplesService.getSingleExampleForm).toHaveBeenCalledWith(
MOCK_REQ_PARAMS.formId,
)
expect(mockRes.status).toBeCalledWith(404)
Expand All @@ -154,7 +154,7 @@ describe('examples.controller', () => {
const mockRes = expressHandler.mockResponse()
// Mock getSingleExampleForm to return database error.
const mockErrorString = 'database error!'
MockExamplesFactory.getSingleExampleForm.mockReturnValueOnce(
MockExamplesService.getSingleExampleForm.mockReturnValueOnce(
errAsync(new DatabaseError(mockErrorString)),
)

Expand All @@ -166,7 +166,7 @@ describe('examples.controller', () => {
)

// Assert
expect(MockExamplesFactory.getSingleExampleForm).toHaveBeenCalledWith(
expect(MockExamplesService.getSingleExampleForm).toHaveBeenCalledWith(
MOCK_REQ_PARAMS.formId,
)
expect(mockRes.status).toBeCalledWith(500)
Expand Down
87 changes: 0 additions & 87 deletions src/app/modules/examples/__tests__/examples.factory.spec.ts

This file was deleted.

Loading