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
|
const { units: unitsOfMarasiDrive } = await got
|
||||||
.get(
|
.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[] }>();
|
.json<{ units: IUnit[] }>();
|
||||||
|
|
||||||
const { units: unitsOfDubaiMarina } = await got
|
const { units: unitsOfDubaiMarina } = await got
|
||||||
.get(
|
.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[] }>();
|
.json<{ units: IUnit[] }>();
|
||||||
|
|
||||||
@@ -26,12 +28,24 @@ for (const {
|
|||||||
suits_area,
|
suits_area,
|
||||||
unit_no,
|
unit_no,
|
||||||
unit_type,
|
unit_type,
|
||||||
|
unit_type_variant,
|
||||||
unit_view,
|
unit_view,
|
||||||
balcony_area,
|
balcony_area,
|
||||||
} of unitsOfMarasiDrive) {
|
} of unitsOfDubaiMarina) {
|
||||||
type Unit = typeof unitsTable.$inferInsert;
|
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 = {
|
const unit: Unit = {
|
||||||
unitNo: unit_no,
|
unitNo: unit_no,
|
||||||
@@ -48,6 +62,9 @@ for (const {
|
|||||||
salesPrice: sales_price,
|
salesPrice: sales_price,
|
||||||
state: state as Unit["state"],
|
state: state as Unit["state"],
|
||||||
unitType: unit_type ? (unit_type as Unit["unitType"]) : null,
|
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,
|
unitView: unit_view ? (unit_view as Unit["unitView"]) : null,
|
||||||
suitsArea: suits_area,
|
suitsArea: suits_area,
|
||||||
squareFt: square_ft,
|
squareFt: square_ft,
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ export const unitsTable = pgTable(
|
|||||||
unitView: varchar("unit_view", {
|
unitView: varchar("unit_view", {
|
||||||
length: 256,
|
length: 256,
|
||||||
}),
|
}),
|
||||||
// unitTypeVariant: varchar("unit_type_variant", {
|
unitTypeVariant: varchar("unit_type_variant", {
|
||||||
// length: 256,
|
length: 256,
|
||||||
// }),
|
}),
|
||||||
suitsArea: doublePrecision("suits_area").notNull(),
|
suitsArea: doublePrecision("suits_area").notNull(),
|
||||||
squareFt: doublePrecision("square_ft").notNull(),
|
squareFt: doublePrecision("square_ft").notNull(),
|
||||||
noOfParkingSpace: integer("no_of_parking_space").notNull(),
|
noOfParkingSpace: integer("no_of_parking_space").notNull(),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ export interface IUnit {
|
|||||||
project: string;
|
project: string;
|
||||||
floor: string;
|
floor: string;
|
||||||
unit_type: string | false;
|
unit_type: string | false;
|
||||||
|
unit_type_variant: string | false;
|
||||||
unit_view: string | false;
|
unit_view: string | false;
|
||||||
no_of_bathrooms: number;
|
no_of_bathrooms: number;
|
||||||
suits_area: number;
|
suits_area: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user