Skip to content

Commit

Permalink
使用データの範囲を明記
Browse files Browse the repository at this point in the history
  • Loading branch information
hideo54 committed Jan 3, 2025
1 parent e7ab4ee commit 2cc1cc7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pages/visits.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { NextPage } from 'next';
import { Open, Square } from '@styled-icons/ionicons-outline';
import { Airplane } from '@styled-icons/ionicons-solid';
import clsx from 'clsx';
import dayjs from 'dayjs';
import { sum } from 'lodash';
import { IconAnchor, IconSpan } from '../components/iconTools';
import { IconAnchor } from '../components/iconTools';
import Layout from '../components/Layout';
import Map from '../components/Map';
import maimaiDataJson from '../lib/maimai-data.json';
Expand Down Expand Up @@ -92,6 +94,14 @@ const App: NextPage = () => {
description='旅好き・hideo54がこれまでに訪れたことのある土地をまとめています。'
>
<h1>訪問歴</h1>
<div className='text-sm'>
このページは自動生成されています。
<br />
使用データの範囲:{' '}
{dayjs(swarmDataJson.oldestCheckinDate).format('YYYY年M月D日')}
{dayjs(swarmDataJson.newestCheckinDate).format('YYYY年M月D日')}
</div>
<section id='senkyoku'>
<h2>訪れたことのある小選挙区</h2>
<Map
Expand Down
7 changes: 7 additions & 0 deletions scripts/getCheckins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from 'fs/promises';
import path from 'path';
import * as turf from '@turf/turf';
import axios from 'axios';
import dayjs from 'dayjs';
import dotenv from 'dotenv';
import type { Feature, Position } from 'geojson';
import isoCountries from 'i18n-iso-countries';
Expand All @@ -20,6 +21,7 @@ interface CheckinResponse {
count: number;
items: {
id: string;
createdAt: number;
private?: boolean;
venue: {
id: string;
Expand Down Expand Up @@ -245,6 +247,9 @@ const getCheckinData = async () => {
).sort((a, b) => - (a[1] - b[1]))
);

const oldestCheckinDate = dayjs(allCheckins[0].createdAt * 1000).format('YYYY-MM-DD');
const newestCheckinDate = dayjs(allCheckins[allCheckins.length - 1].createdAt * 1000).format('YYYY-MM-DD');

const checkinData = {
senkyokuVisitCounts2017,
senkyokuVisitCounts2022,
Expand All @@ -254,6 +259,8 @@ const getCheckinData = async () => {
allVisitedCountryCodes,
allVisitedUSStates,
ramenRestaurantsCheckinCount,
oldestCheckinDate,
newestCheckinDate,
};
return checkinData;
};
Expand Down

0 comments on commit 2cc1cc7

Please sign in to comment.