Skip to content

Commit

Permalink
オーダーストップ情報を出力するスクリプトを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
toririm committed Nov 11, 2024
1 parent d134c62 commit b90f39d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
Binary file modified bun.lockb
Binary file not shown.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"@biomejs/biome": "1.9.3",
"typescript": "^5.6.3"
},
"trustedDependencies": ["@biomejs/biome", "workerd"]
"trustedDependencies": ["@biomejs/biome", "workerd"],
"dependencies": {
"dayjs": "^1.11.13"
}
}
24 changes: 24 additions & 0 deletions scripts/download-master-state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import fs from "node:fs";
import { masterRepository } from "common/repositories/global";
import dayjs from "dayjs";
import timezone from "dayjs/plugin/timezone";
import utc from "dayjs/plugin/utc";

dayjs.extend(utc);
dayjs.extend(timezone);

const masterStateEntity = await masterRepository.get();
const orderStats = masterStateEntity?.orderStats ?? [];

const getJST = (date: Date) => dayjs(date).tz("Asia/Tokyo");

const sohosaiData = orderStats.filter(({ createdAt }) =>
getJST(createdAt).isAfter(dayjs("2024-11-03 10:00").tz()),
);

console.log(
getJST(sohosaiData[0].createdAt),
getJST(sohosaiData[sohosaiData.length - 1].createdAt),
);

fs.writeFileSync("order_stops.json", JSON.stringify(sohosaiData, null, 2));
File renamed without changes.

0 comments on commit b90f39d

Please sign in to comment.