diff --git "a/server/Data\353\252\205\354\204\270\354\204\234.md" "b/server/Data\353\252\205\354\204\270\354\204\234.md"
index 3615953bf15e5796d89986a7d901498574fc5557..ed0b804fdef8bf789f96357f7b0330fd75dd8b35 100644
--- "a/server/Data\353\252\205\354\204\270\354\204\234.md"
+++ "b/server/Data\353\252\205\354\204\270\354\204\234.md"
@@ -8,16 +8,26 @@
∟ Local Code (Do/도)
∟ Local Code (SGG/시군구)
∟ Local Code (EMD/읍면동)
- ∟ Year (연)
- ∟ YYYYMMDD (연/월/일)
- ∟ Outside
- ∟ weather.csv
- ∟ Users
- ∟ ID (사용자 개인 ID)
+ ∟ Outside
+ ∟ YYYY (연)
+ ∟ YYYYMM (연/월)
+ ∟ YYYYMMDD (연/월/일)
∟ weather.csv
- ∟ weights.csv
+ ∟ Users
+ ∟ ID (사용자 개인 ID)
+ ∟ YYYY (연)
+ ∟ YYYYMM (연/월)
+ ∟ YYYYMMDD (연/월/일)
+ ∟ weather.csv
+ ∟ weights.csv
-데이터가 저장되는 경로의 구조입니다.
+데이터가 저장되는 경로의 구조입니다.
+
+- 1차 : 지역별 대분류
+- 2차 : 사용자와 외부 정보 분류
+- 3차 : 연 / 월 / 일 분류
+
+
# 2. Data Format
@@ -37,9 +47,9 @@
사용자가 설정한 장소의 데이터는 다음과 같은 형식으로 저장됩니다.
-| Month | Date | Hour | Minute | Temperature | Humidity | Lights | Future Temperature |
-| :---: | :--: | :--: | :----: | :---------: | :------: | :----: | :------------------: |
-| 월 | 일 | 시 | 분 | 온도(℃) | 습도(%) | 광도 | 단위 시간 후 온도(℃) |
+| Month | Date | Hour | Minute | Temperature | Humidity | Lights |
+| :---: | :--: | :--: | :----: | :---------: | :------: | :----: |
+| 월 | 일 | 시 | 분 | 온도(℃) | 습도(%) | 광도 |
@@ -58,15 +68,15 @@ EUE가 제일 중요하게 수행해야할 부분입니다. 데이터를 학습
- 외부 데이터
- - 온도
- - 습도
- - 기압
- - 풍속
+ - 온도 ( Out Temperature )
+ - 습도 ( Out Humidity )
+ - 기압 ( Out Pressure )
+ - 풍속 ( Out Wind Speed )
- 사용자 데이터
- - 온도
- - 습도
- - 광도
+ - 온도 ( Temperature )
+ - 습도 ( Humidity )
+ - 광도 ( Lights )
diff --git a/server/src/controllers/dataController.js b/server/src/controllers/dataController.js
index 06492a0ef53dcf5dcb7527e31e39b6ef4e5cae0b..2fc718a8a6be4f70045d07e2571d42d35a82e719 100644
--- a/server/src/controllers/dataController.js
+++ b/server/src/controllers/dataController.js
@@ -4,6 +4,9 @@ import fetch from "node-fetch";
const OUT = "Out";
const IN = "In";
+const OUTSIDE = "Outside";
+const USERS = "Users";
+
// 데이터 수집 기로 부터 받아온 지역 코드 세분화
const locCodeSep = (code = "") => {
const DO = code.slice(0, 2);
@@ -40,12 +43,20 @@ const getTimeInfo = () => {
return time;
};
-const getDataDIR = (loc, time) => {
- const repoDIR = `./data/${loc.DO}/${loc.SGG}/${loc.EMD}/${time.year}/${
- time.year
- }${time.month < 10 ? "0" + time.month : time.month}${
- time.date < 10 ? "0" + time.date : time.date
- }`;
+const getDataDIR = (loc, time, id) => {
+ const year = time.year;
+ const month = time.month < 10 ? `0${time.month}` : time.month;
+ const date = time.date < 10 ? `0${time.date}` : time.date;
+
+ const repoDIR =
+ "./data" +
+ `/${loc.DO}` +
+ `/${loc.SGG}` +
+ `/${loc.EMD}` +
+ `/${id}` +
+ `/${year}` +
+ `/${year}${month}` +
+ `/${year}${month}${date}`;
return repoDIR;
};
@@ -65,11 +76,6 @@ const storeData = (type, time, loc, fdir, data) => {
});
console.log("Create directory.");
-
- if (type === IN) {
- data = data.split("\n")[1];
- console.log("Split the user Data.");
- }
}
// 그 외의 에러는 출력
else console.log(err);
@@ -81,7 +87,7 @@ const storeData = (type, time, loc, fdir, data) => {
console.log(
`${time.year}/${time.month}/${time.date} ${time.hour}:${
time.minute
- } - ${loc.EMD} ${type === OUT ? "Outside" : "User"} data append.`
+ } - ${loc.EMD} ${type === OUT ? OUTSIDE : USERS} data append.`
);
});
});
@@ -104,8 +110,8 @@ const handleOutData = (locCode, lat, lng) => {
const loc = locCodeSep(locCode);
const time = getTimeInfo();
- const fdir = getDataDIR(loc, time) + "/Outside";
- // 데이터 형식 - 월 | 일 | 시 | 분 | 온도 | 습도 | 기압 | 풍속
+ const fdir = getDataDIR(loc, time, OUTSIDE);
+ // 데이터 형식 - [ 월 | 일 | 시 | 분 | 온도 | 습도 | 기압 | 풍속 ]
const data = `${time.month},${time.date},${time.hour},${time.minute},${temp},${humi},${press},${wind_speed}\n`;
storeData(OUT, time, loc, fdir, data);
@@ -118,9 +124,9 @@ const handleInData = (id, locCode, temp, humi, lights) => {
const loc = locCodeSep(locCode);
const time = getTimeInfo();
- const fdir = getDataDIR(loc, time) + `/Users/${id}`;
- // 데이터 형식 - [이전 줄 : 현재 온도 ( 이전 기록 기준 단위 시간 후 온도)] , [ 현재 줄 : 월 | 일 | 시 | 분 | 온도 | 습도 | 광도 ]
- const data = `${temp}\n${time.month},${time.date},${time.hour},${time.minute},${temp},${humi},${lights}`;
+ const fdir = getDataDIR(loc, time, `${USERS}/${id}`);
+ // 데이터 형식 - [ 월 | 일 | 시 | 분 | 온도 | 습도 | 광도 ]
+ const data = `${time.month},${time.date},${time.hour},${time.minute},${temp},${humi},${lights}\n`;
storeData(IN, time, loc, fdir, data);
};