Skip to content

Commit

Permalink
chore: Tidy up import, export and names
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Aug 16, 2024
1 parent 398a30e commit 0436b0c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
6 changes: 5 additions & 1 deletion app/data/gdhiRepo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import prisma from "./db";

export const getGDHI2020ByITL3 = async (
const getGDHI2020ByITL3 = async (
itl3: string
): Promise<number> => {
try {
Expand All @@ -20,3 +20,7 @@ export const getGDHI2020ByITL3 = async (
throw Error(`Data error: Unable to find gdhi2020 for itl3 ${itl3}`);
}
};

export const gdhiRepo = {
getGDHI2020ByITL3,
}
6 changes: 5 additions & 1 deletion app/data/itlLookupRepo.ts → app/data/itlRepo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import prisma from "./db";

export const getItl3ByPostcodeDistrict = async (
const getItl3ByPostcodeDistrict = async (
postcodeDistrict: string
): Promise<string> => {
try {
Expand All @@ -22,3 +22,7 @@ export const getItl3ByPostcodeDistrict = async (
throw new Error(`Data error: Unable get get itl3 for postcode district ${postcodeDistrict}`);
}
};

export const itlRepo = {
getItl3ByPostcodeDistrict,
}
8 changes: 4 additions & 4 deletions app/services/calculationService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PrismaClient } from "@prisma/client";
import * as itl3Service from "../services/itlLookupService";
import * as ghdiService from "../services/gdhiService";
import { itlService } from "./itlService";
import { gdhiService } from "./gdhiService";
import { Calculation } from "../schemas/calculationSchema";

const prisma = new PrismaClient();
Expand Down Expand Up @@ -112,8 +112,8 @@ export const getHouseholdData = async (
// TODO: Make columns non-nullable
if (!buildPrice) throw Error("Missing buildPrice");

const itl3 = await itl3Service.getByPostcodeDistrict(postcodeDistrict);
const gdhi = await ghdiService.getByITL3(itl3);
const itl3 = await itlService.getByPostcodeDistrict(postcodeDistrict);
const gdhi = await gdhiService.getByITL3(itl3);

const {
_avg: { monthlyMeanRent: averageRentMonthly },
Expand Down
10 changes: 7 additions & 3 deletions app/services/gdhiService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as repo from './../data/gdhiRepo';
import { gdhiRepo } from "../data/gdhiRepo";

export const getByITL3 = async (itl3: string) => {
return await repo.getGDHI2020ByITL3(itl3);
const getByITL3 = async (itl3: string) => {
return await gdhiRepo.getGDHI2020ByITL3(itl3);
};

export const gdhiService = {
getByITL3,
};
5 changes: 0 additions & 5 deletions app/services/itlLookupService.ts

This file was deleted.

9 changes: 9 additions & 0 deletions app/services/itlService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { itlRepo } from "../data/itlRepo";

const getByPostcodeDistrict = async (postcodeDistrict: string) => {
return await itlRepo.getItl3ByPostcodeDistrict(postcodeDistrict);
}

export const itlService = {
getByPostcodeDistrict,
}

0 comments on commit 0436b0c

Please sign in to comment.