Skip to content

Commit

Permalink
Update lat/long value to use decimal precision
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle1morel committed Feb 21, 2024
1 parent 56f49ea commit 1193a8b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/src/controllers/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ const controller = {
financiallySupported: Object.values(financiallySupportedValues).includes(true),
...financiallySupportedValues,
intakeStatus: toTitleCase(data.form.status),
latitude: parseInt(data.latitude),
longitude: parseInt(data.longitude),
latitude: data.latitude,
longitude: data.longitude,
naturalDisaster: data.naturalDisasterInd,
projectName: data.projectName,
queuePriority: parseInt(data.queuePriority),
Expand Down
4 changes: 2 additions & 2 deletions app/src/db/migrations/20231212000000_init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export async function up(knex: Knex): Promise<void> {
table.text('project_name');
table.text('single_family_units');
table.text('street_address');
table.integer('latitude');
table.integer('longitude');
table.decimal('latitude', 8, 6);
table.decimal('longitude', 9, 6);
table.integer('queue_priority');
table.text('related_permits');
table.text('ast_notes');
Expand Down
9 changes: 5 additions & 4 deletions app/src/db/models/submission.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Prisma } from '@prisma/client';
import { Decimal } from '@prisma/client/runtime/library';

import type { Stamps } from '../stamps';
import type { Submission } from '../../types';
Expand Down Expand Up @@ -26,8 +27,8 @@ export default {
company_name_registered: input.companyNameRegistered,
single_family_units: input.singleFamilyUnits,
street_address: input.streetAddress,
latitude: input.latitude,
longitude: input.longitude,
latitude: input.latitude ? new Decimal(input.latitude) : null,
longitude: input.longitude ? new Decimal(input.longitude) : null,
queue_priority: input.queuePriority,
related_permits: input.relatedPermits,
ast_notes: input.astNotes,
Expand Down Expand Up @@ -73,8 +74,8 @@ export default {
companyNameRegistered: input.company_name_registered,
singleFamilyUnits: input.single_family_units,
streetAddress: input.street_address,
latitude: input.latitude,
longitude: input.longitude,
latitude: input.latitude ? input.latitude.toNumber() : null,
longitude: input.longitude ? input.longitude.toNumber() : null,
queuePriority: input.queue_priority,
relatedPermits: input.related_permits,
astNotes: input.ast_notes,
Expand Down
4 changes: 2 additions & 2 deletions app/src/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ model submission {
project_name String?
single_family_units String?
street_address String?
latitude Int?
longitude Int?
latitude Decimal? @db.Decimal(8, 6)
longitude Decimal? @db.Decimal(9, 6)
queue_priority Int?
related_permits String?
ast_notes String?
Expand Down
4 changes: 2 additions & 2 deletions app/src/services/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ const service = {
financially_supported_non_profit: x.financiallySupportedNonProfit,
financially_supported_housing_coop: x.financiallySupportedHousingCoop,
intake_status: x.intakeStatus,
latitude: x.latitude,
longitude: x.longitude,
latitude: parseFloat(x.latitude as unknown as string),
longitude: parseFloat(x.longitude as unknown as string),
natural_disaster: x.naturalDisaster,
project_name: x.projectName,
queue_priority: x.queuePriority,
Expand Down
4 changes: 2 additions & 2 deletions app/src/types/ChefsSubmissionExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export type ChefsSubmissionExport = {
isIndigenousHousingProviderSupported: boolean;
isNonProfitSupported: boolean;
isHousingCooperativeSupported: boolean;
latitude: string;
longitude: string;
latitude: number;
longitude: number;
naturalDisasterInd: boolean;
projectName: string;
companyNameRegistered: string;
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/form/InputNumber.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const fieldActive: Ref<boolean> = ref(false);
class="w-full"
:class="{ 'p-invalid': errorMessage }"
:disabled="disabled"
:min-fraction-digits="0"
:max-fraction-digits="6"
@focus="fieldActive = true"
@blur="fieldActive = false"
/>
Expand Down

0 comments on commit 1193a8b

Please sign in to comment.