mirror of
https://github.com/15000rpm/Pole-Mapper.git
synced 2026-11-28 11:23:23 +09:00
리프레시 관련 문제 수정 - 캐시 갱신, DB
This commit is contained in:
+20
-8
@@ -109,14 +109,26 @@ export async function getPole(id) {
|
||||
}
|
||||
|
||||
export async function getAllPoles({ gu = '', dong = '', start = '', end = '' } = {}) {
|
||||
let query = supabase.from('poles').select('*').order('timestamp', { ascending: false });
|
||||
if (gu) query = query.eq('gu', gu);
|
||||
if (dong) query = query.eq('dong', dong);
|
||||
if (start) query = query.gte('timestamp', start);
|
||||
if (end) query = query.lte('timestamp', end);
|
||||
const { data, error } = await query;
|
||||
if (error) throw error;
|
||||
return (data || []).map((p) => ({
|
||||
// Supabase(PostgREST)는 한 번에 최대 1000행만 돌려주므로 페이지 단위로 모두 읽는다.
|
||||
const PAGE = 1000;
|
||||
const rows = [];
|
||||
for (let from = 0; ; from += PAGE) {
|
||||
let query = supabase
|
||||
.from('poles')
|
||||
.select('*')
|
||||
.order('timestamp', { ascending: false })
|
||||
.order('id', { ascending: true })
|
||||
.range(from, from + PAGE - 1);
|
||||
if (gu) query = query.eq('gu', gu);
|
||||
if (dong) query = query.eq('dong', dong);
|
||||
if (start) query = query.gte('timestamp', start);
|
||||
if (end) query = query.lte('timestamp', end);
|
||||
const { data, error } = await query;
|
||||
if (error) throw error;
|
||||
rows.push(...(data || []));
|
||||
if (!data || data.length < PAGE) break;
|
||||
}
|
||||
return rows.map((p) => ({
|
||||
...p,
|
||||
photoUrl: p.photo_path ? `/uploads/${p.photo_path}` : null,
|
||||
}));
|
||||
|
||||
@@ -23,6 +23,12 @@ const CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
// API 응답은 항상 최신 데이터를 쓰도록 캐시를 금지한다.
|
||||
// (Apache의 ExpiresDefault가 1개월 캐시를 붙이는 것을 막는다)
|
||||
app.use('/api', (_req, res, next) => {
|
||||
res.set('Cache-Control', 'no-store');
|
||||
next();
|
||||
});
|
||||
app.use(express.json());
|
||||
app.use('/uploads', express.static(UPLOAD_DIR));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user