Compare commits
4 Commits
59a94f08e6
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b0d5b3023 | |||
| 2239533fb5 | |||
| 5a059641b4 | |||
| 9aa12420e8 |
1
.env
1
.env
@@ -5,3 +5,4 @@
|
||||
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
||||
|
||||
DATABASE_URL="file:./prisma/dev.db"
|
||||
TZ=Asia/Seoul
|
||||
@@ -29,6 +29,7 @@
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "bun run starter.ts"
|
||||
"start": "bun run starter.ts",
|
||||
"postinstall": "bun x prisma generate"
|
||||
}
|
||||
}
|
||||
|
||||
7
railpack.json
Normal file
7
railpack.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"deploy": {
|
||||
"variables": {
|
||||
"TZ": "Asia/Seoul"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
testUsers,
|
||||
type TelegramUser,
|
||||
} from "./services/telegram.service";
|
||||
|
||||
import type { RealEstateArticle } from "./generated/prisma";
|
||||
import * as XLSX from "xlsx";
|
||||
import { unlink } from "node:fs/promises";
|
||||
@@ -21,6 +22,41 @@ const telegramService = new TelegramService(
|
||||
false
|
||||
);
|
||||
|
||||
function splitAddress(
|
||||
detailAddress: string | null | undefined,
|
||||
baseAddress: string
|
||||
) {
|
||||
const safeDetail = detailAddress?.trim() || "";
|
||||
const base = baseAddress.trim();
|
||||
|
||||
if (!safeDetail) {
|
||||
return { address: base, detailAddress: "" };
|
||||
}
|
||||
|
||||
const match = safeDetail.match(
|
||||
/(^|[\s,])([\d]{1,6}(?:-[\d]{1,6})?)(?:\s*번지)?(?=[\s,]|$)/
|
||||
);
|
||||
if (!match) {
|
||||
return { address: base, detailAddress: safeDetail };
|
||||
}
|
||||
|
||||
const rawToken = match[2];
|
||||
if (!rawToken) {
|
||||
return { address: base, detailAddress: safeDetail };
|
||||
}
|
||||
|
||||
const lot = rawToken.replace(/\s+/g, "");
|
||||
const removed = safeDetail
|
||||
.replace(new RegExp(`(^|[\\s,])${rawToken}(?:\\s*번지)?(?=[\\s,]|$)`), "")
|
||||
.replace(/\s{2,}/g, " ")
|
||||
.trim();
|
||||
|
||||
return {
|
||||
address: [base, lot].filter(Boolean).join(" ").trim(),
|
||||
detailAddress: removed,
|
||||
};
|
||||
}
|
||||
|
||||
function logWithTime(...args: unknown[]) {
|
||||
console.log(`[${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`, ...args);
|
||||
}
|
||||
@@ -106,6 +142,10 @@ async function createExcelFile(
|
||||
const getPrice = () => {
|
||||
return item.prcInfo;
|
||||
};
|
||||
const normalizedAddress = splitAddress(
|
||||
item.detailAddress || "",
|
||||
`${item.city || ""} ${item.division || ""} ${item.sector || ""}`
|
||||
);
|
||||
|
||||
return {
|
||||
매물번호: item.articleNumber,
|
||||
@@ -113,8 +153,8 @@ async function createExcelFile(
|
||||
소유자구분: getOwnerType(),
|
||||
매물형태: item.articleName || "",
|
||||
매매구분: item.tradTpNm || "",
|
||||
주소: `${item.city || ""} ${item.division || ""} ${item.sector || ""}`,
|
||||
상세주소: item.detailAddress || "",
|
||||
주소: normalizedAddress.address,
|
||||
상세주소: normalizedAddress.detailAddress,
|
||||
층수: item.floorInfo || "",
|
||||
가격: getPrice(),
|
||||
매물특징: item.articleDescription || "",
|
||||
|
||||
Reference in New Issue
Block a user