Update unit retrieval logic and schema to include unitTypeVariant
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
name: "irth-new-server:4002",
|
||||
script: "bun ./dist/index.js",
|
||||
};
|
||||
+21
-4
@@ -5,13 +5,15 @@ import got from "got";
|
||||
|
||||
const { units: unitsOfMarasiDrive } = await got
|
||||
.get(
|
||||
"https://irth-test-ii-16348121.dev.odoo.com/3d-fields/1?token=f82a4708-9a4d-491a-9424-1580b7173ba6"
|
||||
// "https://irth-test-ii-16348121.dev.odoo.com/3d-fields/1?token=f82a4708-9a4d-491a-9424-1580b7173ba6"
|
||||
"https://irth.odoo.com/3d-fields/50?token=f82a4708-9a4d-491a-9424-1580b7173ba6"
|
||||
)
|
||||
.json<{ units: IUnit[] }>();
|
||||
|
||||
const { units: unitsOfDubaiMarina } = await got
|
||||
.get(
|
||||
"https://irth-test-ii-16348121.dev.odoo.com/3d-fields/7?token=f82a4708-9a4d-491a-9424-1580b7173ba6"
|
||||
// "https://irth-test-ii-16348121.dev.odoo.com/3d-fields/7?token=f82a4708-9a4d-491a-9424-1580b7173ba6"
|
||||
"https://irth.odoo.com/3d-fields/1?token=f82a4708-9a4d-491a-9424-1580b7173ba6"
|
||||
)
|
||||
.json<{ units: IUnit[] }>();
|
||||
|
||||
@@ -26,12 +28,24 @@ for (const {
|
||||
suits_area,
|
||||
unit_no,
|
||||
unit_type,
|
||||
unit_type_variant,
|
||||
unit_view,
|
||||
balcony_area,
|
||||
} of unitsOfMarasiDrive) {
|
||||
} of unitsOfDubaiMarina) {
|
||||
type Unit = typeof unitsTable.$inferInsert;
|
||||
|
||||
const parts = unit_no.split("-");
|
||||
let parts: string[];
|
||||
|
||||
if (unit_no.includes("Retail")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
parts = unit_no.split("-");
|
||||
} catch (error) {
|
||||
console.log(unit_no);
|
||||
continue;
|
||||
}
|
||||
|
||||
const unit: Unit = {
|
||||
unitNo: unit_no,
|
||||
@@ -48,6 +62,9 @@ for (const {
|
||||
salesPrice: sales_price,
|
||||
state: state as Unit["state"],
|
||||
unitType: unit_type ? (unit_type as Unit["unitType"]) : null,
|
||||
unitTypeVariant: unit_type_variant
|
||||
? (unit_type_variant as Unit["unitTypeVariant"])
|
||||
: null,
|
||||
unitView: unit_view ? (unit_view as Unit["unitView"]) : null,
|
||||
suitsArea: suits_area,
|
||||
squareFt: square_ft,
|
||||
|
||||
@@ -17,9 +17,9 @@ export const unitsTable = pgTable(
|
||||
unitView: varchar("unit_view", {
|
||||
length: 256,
|
||||
}),
|
||||
// unitTypeVariant: varchar("unit_type_variant", {
|
||||
// length: 256,
|
||||
// }),
|
||||
unitTypeVariant: varchar("unit_type_variant", {
|
||||
length: 256,
|
||||
}),
|
||||
suitsArea: doublePrecision("suits_area").notNull(),
|
||||
squareFt: doublePrecision("square_ft").notNull(),
|
||||
noOfParkingSpace: integer("no_of_parking_space").notNull(),
|
||||
|
||||
@@ -3,6 +3,7 @@ export interface IUnit {
|
||||
project: string;
|
||||
floor: string;
|
||||
unit_type: string | false;
|
||||
unit_type_variant: string | false;
|
||||
unit_view: string | false;
|
||||
no_of_bathrooms: number;
|
||||
suits_area: number;
|
||||
|
||||
Reference in New Issue
Block a user