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/bulk/all #2020

Merged
merged 26 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
32f2105
feat: bulk frontend modal (#1958)
gweiying Sep 13, 2022
59f8fdb
chore: refactor FileInputField component (#1960)
gweiying Sep 15, 2022
178ea8d
feat: connect bulk csv upload to backend
Sep 28, 2022
ffa73e3
fix: tag serialization and deserialization on FormData
gweiying Oct 10, 2022
601171e
fix: renamed button
gweiying Oct 10, 2022
6126853
chore: add e2e tests for bulk creation (#2022)
gweiying Oct 13, 2022
77c294a
feat(bulk-backend): Job and JobItem DB model, repository and service …
jimvae Oct 16, 2022
07845ec
chore: add error message for invalid date string and csv header
Oct 17, 2022
e97a41c
Feat/bulk/frontend/status bar (#2040)
gweiying Nov 7, 2022
40dcf3a
Feat/bulk/frontend/status bar button (#2047)
gweiying Nov 15, 2022
65ffbcb
Feat/bulk/all lambda (#2033)
jimvae Nov 15, 2022
e3ec1e3
Feat/bulk/all cleanup unused (#2082)
gweiying Nov 15, 2022
c802416
Feat/bulk/all create job (#2083)
gweiying Nov 25, 2022
657ac2f
Feat/bulk/all update job (#2085)
gweiying Nov 28, 2022
5b35d05
Feat/bulk/all get job server (#2092)
gweiying Nov 28, 2022
0f98c28
Feat/bulk/all get job client (#2093)
gweiying Nov 28, 2022
75a55d4
Feat/bulk/all email send (#2099)
gweiying Nov 29, 2022
4039da8
Merge branch 'develop' into feat/bulk/all
gweiying Nov 29, 2022
f177fad
chore: fix copy (#2103)
gweiying Nov 29, 2022
d573930
Feat/bulk/all api guard (#2104)
gweiying Nov 30, 2022
d547c9c
chore: fix email copy (#2107)
gweiying Dec 5, 2022
89a1143
Merge branch 'develop' into feat/bulk/all
gweiying Dec 5, 2022
52b7a6b
chore: get header from shared folder
gweiying Dec 5, 2022
49f23dd
chore: create shared types for bulk download file names
gweiying Dec 5, 2022
3d9f8da
chore: remove duplicate REPLICA_URI
gweiying Dec 5, 2022
72fd798
chore: add unauthorized error message
gweiying Dec 5, 2022
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
12 changes: 11 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,15 @@
"extensions": [".jsx", ".js", ".tsx", ".ts", ".scss", ".css", ".png", ".svg"]
}
}
}
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"rules": {
// Disabling `no-undef` lint rule in favor of Typescript checking
// https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/TROUBLESHOOTING.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
"no-undef": "off"
}
}
]
}
2 changes: 1 addition & 1 deletion Dockerfile.maildev-logging
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM maildev/maildev:1.1.0
WORKDIR /usr/src/app
RUN echo "maildev.on('new', ({ html }) => console.log('Login OTP: ' + html.match(/\d{6}/)[0]))" >> bin/maildev
RUN echo "maildev.on('new', ({ html }) => { if(html.includes('OTP')) { console.log('Login OTP: ' + html.match(/\d{6}/)[0]) } else { console.log(html) } } )" >> bin/maildev
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,19 @@ After these have been set up, set the environment variables according to the tab
|COOKIE_MAX_AGE|Yes|Session duration of cookie|
|BULK_UPLOAD_MAX_NUM|No|Maximum number of links that can be bulk uploaded at once. Defaults to 1000|
|BULK_UPLOAD_RANDOM_STR_LENGTH|No|String length of randomly generated shortUrl in bulk upload. Defaults to 8|
|BULK_QR_CODE_BATCH_SIZE|No|Maximum batch size of QR codes to generate in a single Lambda run. Defaults to 1000|
|BULK_QR_CODE_BUCKET_URL|No|Link to download QR codes from|
|ACTIVATE_BULK_QR_CODE_GENERATION|No|Whether to start Lambda for bulk QR code generation or not. Defaults to false|
|REPLICA_URI|Yes|The postgres connection string, e.g. `postgres://postgres:postgres@postgres:5432/postgres`|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REPLICA_URI here appears to be a duplicate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|SQS_BULK_QRCODE_GENERATE_START_URL|No|The SQS queue for starting QR code bulk generation Lambda|
|SQS_TIMEOUT|No|Duration of time in ms for sending to SQS queue before timeout. Defaults to 10000ms (10s)|
|SQS_REGION|No|AWS Region of SQS queue for starting QR code bulk generation Lambda|
|JOB_POLL_ATTEMPTS|No|Number of attempts for long polling of job status before timeout of 408 is returned. Defaults to 12|
|JOB_POLL_INTERVAL|No|Interval of time between attempts for long polling of job status in ms. Defaults to 5000ms (5s)|
|API_LINK_RANDOM_STR_LENGTH|No|String length of randomly generated shortUrl in API created links. Defaults to 8|
|REPLICA_URI|Yes|The postgres connection string, e.g. `postgres://postgres:postgres@postgres:5432/postgres`|
|FF_EXTERNAL_API|No|Boolean, feature flag for enabling the external API. Defaults to false|
|ADMIN_API_EMAIL|No|Email with admin API access. Defaults to none.|

#### Serverless functions for link migration

Expand Down
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,18 @@ services:
- ACTIVATE_POSTMAN_FALLBACK=
- BULK_UPLOAD_MAX_NUM=1000
- BULK_UPLOAD_RANDOM_STR_LENGTH=8
- SQS_BULK_QRCODE_GENERATE_START_URL=
- SQS_TIMEOUT=10000
- SQS_REGION=
- BULK_QR_CODE_BATCH_SIZE=1000
- ACTIVATE_BULK_QR_CODE_GENERATION=false
- JOB_POLL_ATTEMPTS=12
- JOB_POLL_INTERVAL=5000
- BULK_QR_CODE_BUCKET_URL=
- API_LINK_RANDOM_STR_LENGTH=8
- API_KEY_SALT=$$2b$$10$$9rBKuE4Gb5ravnvP4xjoPu
- FF_EXTERNAL_API=true
- ADMIN_API_EMAIL=
volumes:
- ./public:/usr/src/gogovsg/public
- ./src:/usr/src/gogovsg/src
Expand Down
178 changes: 178 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@sentry/webpack-plugin": "^1.15.1",
"@types/express-rate-limit": "^5.1.3",
"@types/papaparse": "^5.3.5",
"archiver": "^5.3.1",
"aws-sdk": "^2.1101.0",
"babel-polyfill": "^6.26.0",
"bcrypt": "^5.1.0",
Expand Down
13 changes: 12 additions & 1 deletion serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,16 @@ functions:
- 'src/server/serverless/capture-ses-events/**'
- 'package-lock.json'
- 'package.json'

bulk-qrcode-generation:
handler: src/server/serverless/bulk-qrcode-generation/index.handler
memorySize: 2048 # 2048 MB
ephemeralStorageSize: 512 # 512 MB
timeout: 120 # 120 seconds
description: Bulk generates QR codes in svg and png from shortUrl-longUrl mappings
package:
patterns:
- '!./**'
- 'src/server/serverless/bulk-qrcode-generation/**'
- 'package-lock.json'
- 'package.json'

32 changes: 22 additions & 10 deletions src/client/app/util/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ import { GAEvent } from './ga'
import { UrlTableConfig } from '../../user/reducers/types'
import queryObjFromTableConfig from '../helpers/urlQueryHelper'

export const downloadCsv = (csvString: string, filename: string) => {
const blob = new Blob([csvString], {
type: 'text/csv;charset=utf-8',
})

if (useIsIE()) {
navigator.msSaveBlob(blob, filename)
} else {
saveAs(blob, filename)
}
}

export const downloadSampleBulkCsv = () => {
const headers = 'Original links to be shortened'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could this be taken from src/shared/constants.ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes 52b7a6b

const body = ['https://www.link1.com', 'https://www.link2.com']
const content = [headers, ...body].join('\r\n')
downloadCsv(content, 'sample_bulk.csv')
GAEvent('modal page', 'downloaded bulk sample', 'successful')
}

export const downloadUrls = async (tableConfig: UrlTableConfig) => {
const urlsArr = []
// set headers to csv
Expand Down Expand Up @@ -59,22 +79,14 @@ export const downloadUrls = async (tableConfig: UrlTableConfig) => {
rootActions.setErrorMessage('Error downloading urls.')
return null
}

const blob = new Blob([urlsArr.join('')], {
type: 'text/csv;charset=utf-8',
})

if (useIsIE()) {
navigator.msSaveBlob(blob, 'urls.csv')
} else {
saveAs(blob, 'urls.csv')
}
downloadCsv(urlsArr.join(''), 'urls.csv')

// Google Analytics: Download links button events
GAEvent('user page', 'download links button', 'successful')
return null
}

export default {
downloadSampleBulkCsv,
downloadUrls,
}
Loading