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

406 - the docket number will reset to 1 on a new year #561

Merged
merged 4 commits into from
Jan 7, 2019
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
4 changes: 3 additions & 1 deletion SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ The end result of this is not a dev, staging, or production website, but is inst
- [Create a SonarCloud account](https://sonarcloud.io/). SonarCloud will be used to tests each build.
- [Create a new SonarCloud organization](https://sonarcloud.io/create-organization).
- [Create a token](https://sonarcloud.io/account/security) that Jenkins can use to interact with SonarCloud. (This will be referred to as `SONAR_TOKEN` when setting up Jenkins.)
- There are two sub-projects to the EF-CMS — the front-end (the UI) and the back-end (the API). Each is handled separately by Jenkins and SonarCloud.
- There are three sub-projects to the EF-CMS — the front-end (the UI), the back-end (the API), and shared code. Each is handled separately by Jenkins and SonarCloud.
- [Create a project and project key](https://sonarcloud.io/projects/create?manual=true) for the UI. (This will be referred to as `UI_SONAR_TOKEN` when setting up Jenkins.)
- [Create a project and project key](https://sonarcloud.io/projects/create?manual=true) for the API. (This will be referred to as `API_SONAR_TOKEN` when setting up Jenkins.)
- [Create a project and project key](https://sonarcloud.io/projects/create?manual=true) for the SHARED code. (This will be referred to as `SHARED_SONAR_TOKEN` when setting up Jenkins.)

## Setup Steps

Expand Down Expand Up @@ -63,6 +64,7 @@ The end result of this is not a dev, staging, or production website, but is inst
- `EFCMS_DOMAIN` / your subdomain, e.g. `ef-cms.example.gov`
- `UI_SONAR_KEY` / your Sonar UI project key, e.g. `ef-cms-ui`
- `API_SONAR_KEY` / your Sonar API project key, e.g. `ef-cms-api`
- `SHARED_SONAR_KEY` / your Sonar API project key, e.g. `ef-cms-shared`

11. At the CLI, set up the jobs via the `setup-jobs.sh` script, which is in `management/bin/`. This script takes three arguments, with a complete command like: `../bin/setup-jobs.sh https://github.com/flexion/ef-cms.git flexion ef-cms`. Those arguments are, in this order:
- Your Git repository’s URL, e.g. `https://github.com/examplecourt/ef-cms.git`.
Expand Down
6 changes: 4 additions & 2 deletions shared/src/persistence/awsDynamoPersistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ exports.getRecordViaMapping = getRecordViaMapping;
exports.incrementCounter = ({ applicationContext }) => {
const TABLE = `efcms-${applicationContext.environment.stage}`;

const year = new Date().getFullYear().toString();

return client.updateConsistent({
applicationContext,
TableName: TABLE,
Key: {
pk: 'docketNumberCounter',
sk: 'docketNumberCounter', // TODO: set sk by the year, i.e. 2018
pk: `docketNumberCounter-${year}`,
Copy link

Choose a reason for hiding this comment

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

@codyseibert Why is the format of a docket number a rule enforced by the persistence gateway? Or am I misunderstanding what's really going on here?

sk: `docketNumberCounter-${year}`,
},
UpdateExpression: 'ADD #a :x',
ExpressionAttributeNames: {
Expand Down
6 changes: 4 additions & 2 deletions shared/src/persistence/awsDynamoPersistence.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ describe('awsDynamoPersistence', function() {
describe('incrementCounter', () => {
it('should invoke the correct client updateConsistence method using the correct pk and sk', async () => {
await incrementCounter({ applicationContext });
const year = new Date().getFullYear().toString();

expect(client.updateConsistent.getCall(0).args[0].Key.pk).to.equal(
'docketNumberCounter',
`docketNumberCounter-${year}`,
);
expect(client.updateConsistent.getCall(0).args[0].Key.sk).to.equal(
'docketNumberCounter',
`docketNumberCounter-${year}`,
);
});
});
Expand Down