Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
Bug/co2 double (#26)
Browse files Browse the repository at this point in the history
* Switch column embodied_co2 to be a double as the calculation can result in none integer amounts

* 0.5.2

* typo
  • Loading branch information
mattdean-digicatapult authored Dec 8, 2023
1 parent 0cc3047 commit b8a8090
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digicatapult/dscp-hyproof-api",
"version": "0.5.1",
"version": "0.5.2",
"description": "An OpenAPI API service for DSCP",
"main": "src/index.ts",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/controllers/v1/certificate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class CertificateController extends Controller {
...cert,
energy_owner: (await getMemberPromise(cert.energy_owner)).alias,
hydrogen_owner: (await getMemberPromise(cert.hydrogen_owner)).alias,
regulator: (await getMemberPromise(cert.regulator)).alias,
}
})
)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/db/migrations/20230310111029_initial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export async function up(knex: Knex): Promise<void> {

await knex.schema.createTable('certificate', (def) => {
def.uuid('id').defaultTo(knex.raw('uuid_generate_v4()'))
def.integer('hydrogen_quantity_mwh').notNullable().index('hydrogen_quantity_mwh_index')
def.integer('embodied_co2').nullable().index('embodied_co2_index').defaultTo(null)
def.integer('hydrogen_quantity_mwh').notNullable()
def.double('embodied_co2').nullable().defaultTo(null)
def.string('energy_owner', 48).notNullable()
def.string('hydrogen_owner', 48).notNullable()
def.string('regulator', 48).notNullable()
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function withExternalServicesMock() {
from: '2023-12-01T00:00:00.000Z',
to: '2023-12-02T00:00:00.000Z',
intensity: {
actual: 100,
actual: 123.456789123,
forecast: 100,
index: 'moderate',
},
Expand Down
2 changes: 1 addition & 1 deletion test/integration/onchain/certificate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('on-chain', function () {
expect(cert).to.deep.contain({
id: context.cert.id,
state: 'issued',
embodied_co2: 200000,
embodied_co2: 246913.578246,
latest_token_id: lastTokenId + 1,
})
})
Expand Down

0 comments on commit b8a8090

Please sign in to comment.