Showing
18 changed files
with
822 additions
and
64 deletions
This diff is collapsed. Click to expand it.
| ... | @@ -8,8 +8,9 @@ | ... | @@ -8,8 +8,9 @@ |
| 8 | "@testing-library/react": "^9.3.2", | 8 | "@testing-library/react": "^9.3.2", |
| 9 | "@testing-library/user-event": "^7.1.2", | 9 | "@testing-library/user-event": "^7.1.2", |
| 10 | "axios": "^0.19.2", | 10 | "axios": "^0.19.2", |
| 11 | - "immer": "^7.0.1", | 11 | + "immer": "^7.0.5", |
| 12 | "include-media": "^1.4.9", | 12 | "include-media": "^1.4.9", |
| 13 | + "moment": "^2.27.0", | ||
| 13 | "open-color": "^1.7.0", | 14 | "open-color": "^1.7.0", |
| 14 | "react": "^16.13.1", | 15 | "react": "^16.13.1", |
| 15 | "react-dom": "^16.13.1", | 16 | "react-dom": "^16.13.1", | ... | ... |
| 1 | import React from 'react'; | 1 | import React from 'react'; |
| 2 | import { makeStyles } from '@material-ui/core/styles'; | 2 | import { makeStyles } from '@material-ui/core/styles'; |
| 3 | -import styled from 'styled-components'; | ||
| 4 | -import palette from '../../lib/styles/palette'; | ||
| 5 | import Button from '@material-ui/core/Button'; | 3 | import Button from '@material-ui/core/Button'; |
| 6 | import TextField from '@material-ui/core/TextField'; | 4 | import TextField from '@material-ui/core/TextField'; |
| 7 | 5 | ... | ... |
| 1 | import React from 'react'; | 1 | import React from 'react'; |
| 2 | -import styled from 'styled-components'; | ||
| 3 | -import Button from '../common/Button'; | ||
| 4 | import palette from '../../lib/styles/palette'; | 2 | import palette from '../../lib/styles/palette'; |
| 5 | import BJIDForm from './BJIDForm'; | 3 | import BJIDForm from './BJIDForm'; |
| 4 | +import SlackForm from './SlackForm'; | ||
| 6 | import { makeStyles } from '@material-ui/core/styles'; | 5 | import { makeStyles } from '@material-ui/core/styles'; |
| 7 | import Paper from '@material-ui/core/Paper'; | 6 | import Paper from '@material-ui/core/Paper'; |
| 8 | import Grid from '@material-ui/core/Grid'; | 7 | import Grid from '@material-ui/core/Grid'; |
| 9 | 8 | ||
| 10 | -const SettingFormBlock = styled.div` | ||
| 11 | - h3 { | ||
| 12 | - margin: 0; | ||
| 13 | - color: ${palette.gray[8]}; | ||
| 14 | - margin-bottom: 1rem; | ||
| 15 | - } | ||
| 16 | - background: ${palette.gray[2]}; | ||
| 17 | - margin: 0 auto; | ||
| 18 | - display: flex; | ||
| 19 | - flex-direction: column; | ||
| 20 | -`; | ||
| 21 | -const StyledInput = styled.input` | ||
| 22 | - font-size: 1rem; | ||
| 23 | - border: none; | ||
| 24 | - border-bottom: 1px solid ${palette.gray[5]}; | ||
| 25 | - padding-bottom: 0.5rem; | ||
| 26 | - outline: none; | ||
| 27 | - &:focus { | ||
| 28 | - color: $oc-teal-7; | ||
| 29 | - border-bottom: 1px solid ${palette.gray[7]}; | ||
| 30 | - } | ||
| 31 | - & + & { | ||
| 32 | - margin-top: 1rem; | ||
| 33 | - } | ||
| 34 | -`; | ||
| 35 | -const SectionContainer = styled.div` | ||
| 36 | - display: flex; | ||
| 37 | -`; | ||
| 38 | - | ||
| 39 | const useStyles = makeStyles((theme) => ({ | 9 | const useStyles = makeStyles((theme) => ({ |
| 40 | root: { | 10 | root: { |
| 41 | flexGrow: 1, | 11 | flexGrow: 1, |
| ... | @@ -48,7 +18,13 @@ const useStyles = makeStyles((theme) => ({ | ... | @@ -48,7 +18,13 @@ const useStyles = makeStyles((theme) => ({ |
| 48 | }, | 18 | }, |
| 49 | })); | 19 | })); |
| 50 | 20 | ||
| 51 | -const SettingForm = ({ onChange, onBJIDSubmit, profile, onSyncBJIDSubmit }) => { | 21 | +const SettingForm = ({ |
| 22 | + onChange, | ||
| 23 | + onBJIDSubmit, | ||
| 24 | + onSlackURLSubmit, | ||
| 25 | + profile, | ||
| 26 | + onSyncBJIDSubmit, | ||
| 27 | +}) => { | ||
| 52 | const classes = useStyles(); | 28 | const classes = useStyles(); |
| 53 | return ( | 29 | return ( |
| 54 | <div className={classes.root}> | 30 | <div className={classes.root}> |
| ... | @@ -68,6 +44,16 @@ const SettingForm = ({ onChange, onBJIDSubmit, profile, onSyncBJIDSubmit }) => { | ... | @@ -68,6 +44,16 @@ const SettingForm = ({ onChange, onBJIDSubmit, profile, onSyncBJIDSubmit }) => { |
| 68 | /> | 44 | /> |
| 69 | </Paper> | 45 | </Paper> |
| 70 | </Grid> | 46 | </Grid> |
| 47 | + | ||
| 48 | + <Grid container item xs={12}> | ||
| 49 | + <Paper className={classes.paper} elevation={3}> | ||
| 50 | + <SlackForm | ||
| 51 | + profile={profile} | ||
| 52 | + onChange={onChange} | ||
| 53 | + onSlackURLSubmit={onSlackURLSubmit} | ||
| 54 | + /> | ||
| 55 | + </Paper> | ||
| 56 | + </Grid> | ||
| 71 | </Grid> | 57 | </Grid> |
| 72 | </div> | 58 | </div> |
| 73 | ); | 59 | ); | ... | ... |
| 1 | +import React from 'react'; | ||
| 2 | +import { makeStyles } from '@material-ui/core/styles'; | ||
| 3 | + | ||
| 4 | +import Button from '@material-ui/core/Button'; | ||
| 5 | +import TextField from '@material-ui/core/TextField'; | ||
| 6 | + | ||
| 7 | +const useStyles = makeStyles((theme) => ({ | ||
| 8 | + root: { | ||
| 9 | + '& > *': { | ||
| 10 | + margin: theme.spacing(1), | ||
| 11 | + }, | ||
| 12 | + }, | ||
| 13 | +})); | ||
| 14 | + | ||
| 15 | +const SlackForm = ({ onChange, profile, onSlackURLSubmit }) => { | ||
| 16 | + const classes = useStyles(); | ||
| 17 | + return ( | ||
| 18 | + <div> | ||
| 19 | + <form onSubmit={onSlackURLSubmit}> | ||
| 20 | + <TextField | ||
| 21 | + name="slackWebHookURL" | ||
| 22 | + onChange={onChange} | ||
| 23 | + value={profile.slackWebHookURL} | ||
| 24 | + placeholder="슬랙 Webhook URL" | ||
| 25 | + label="슬랙 Webhook URL" | ||
| 26 | + /> | ||
| 27 | + <Button variant="outlined" type="submit"> | ||
| 28 | + 등록 | ||
| 29 | + </Button> | ||
| 30 | + </form> | ||
| 31 | + </div> | ||
| 32 | + ); | ||
| 33 | +}; | ||
| 34 | + | ||
| 35 | +export default SlackForm; |
| 1 | -import React, { useEffect, useState } from 'react'; | 1 | +import React, { useEffect } from 'react'; |
| 2 | import { useDispatch, useSelector } from 'react-redux'; | 2 | import { useDispatch, useSelector } from 'react-redux'; |
| 3 | import { withRouter } from 'react-router-dom'; | 3 | import { withRouter } from 'react-router-dom'; |
| 4 | import HomeForm from '../../components/home/HomeForm'; | 4 | import HomeForm from '../../components/home/HomeForm'; |
| ... | @@ -6,16 +6,12 @@ import { getPROFILE } from '../../modules/profile'; | ... | @@ -6,16 +6,12 @@ import { getPROFILE } from '../../modules/profile'; |
| 6 | import { analyzeBJ } from '../../lib/util/analyzeBJ'; | 6 | import { analyzeBJ } from '../../lib/util/analyzeBJ'; |
| 7 | const HomeContainer = ({ history }) => { | 7 | const HomeContainer = ({ history }) => { |
| 8 | const dispatch = useDispatch(); | 8 | const dispatch = useDispatch(); |
| 9 | - const [isLogin, setLogin] = useState(false); | ||
| 10 | const { user, profile } = useSelector(({ user, profile }) => ({ | 9 | const { user, profile } = useSelector(({ user, profile }) => ({ |
| 11 | user: user.user, | 10 | user: user.user, |
| 12 | profile: profile, | 11 | profile: profile, |
| 13 | })); | 12 | })); |
| 13 | + useEffect(() => {}, [profile.solvedBJ]); | ||
| 14 | useEffect(() => { | 14 | useEffect(() => { |
| 15 | - analyzeBJ(profile.solvedBJ); | ||
| 16 | - }, [profile.solvedBJ]); | ||
| 17 | - useEffect(() => { | ||
| 18 | - setLogin(true); | ||
| 19 | if (user) { | 15 | if (user) { |
| 20 | let username = user.username; | 16 | let username = user.username; |
| 21 | dispatch(getPROFILE({ username })); | 17 | dispatch(getPROFILE({ username })); | ... | ... |
| 1 | -import React, { useEffect, useState } from 'react'; | 1 | +import React, { useEffect } from 'react'; |
| 2 | import { useDispatch, useSelector } from 'react-redux'; | 2 | import { useDispatch, useSelector } from 'react-redux'; |
| 3 | import { withRouter } from 'react-router-dom'; | 3 | import { withRouter } from 'react-router-dom'; |
| 4 | import { | 4 | import { |
| ... | @@ -7,6 +7,7 @@ import { | ... | @@ -7,6 +7,7 @@ import { |
| 7 | getPROFILE, | 7 | getPROFILE, |
| 8 | syncBJID, | 8 | syncBJID, |
| 9 | initializeProfile, | 9 | initializeProfile, |
| 10 | + setSLACK, | ||
| 10 | } from '../../modules/profile'; | 11 | } from '../../modules/profile'; |
| 11 | import SettingForm from '../../components/setting/SettingForm'; | 12 | import SettingForm from '../../components/setting/SettingForm'; |
| 12 | 13 | ||
| ... | @@ -32,6 +33,12 @@ const SettingContainer = ({ history }) => { | ... | @@ -32,6 +33,12 @@ const SettingContainer = ({ history }) => { |
| 32 | let username = profile.username; | 33 | let username = profile.username; |
| 33 | dispatch(syncBJID({ username })); | 34 | dispatch(syncBJID({ username })); |
| 34 | }; | 35 | }; |
| 36 | + const onSlackURLSubmit = (e) => { | ||
| 37 | + e.preventDefault(); | ||
| 38 | + let username = profile.username; | ||
| 39 | + let slackWebHookURL = profile.slackWebHookURL; | ||
| 40 | + dispatch(setSLACK({ username, slackWebHookURL })); | ||
| 41 | + }; | ||
| 35 | 42 | ||
| 36 | const onBJIDSubmit = (e) => { | 43 | const onBJIDSubmit = (e) => { |
| 37 | e.preventDefault(); | 44 | e.preventDefault(); |
| ... | @@ -60,6 +67,7 @@ const SettingContainer = ({ history }) => { | ... | @@ -60,6 +67,7 @@ const SettingContainer = ({ history }) => { |
| 60 | onChange={onChange} | 67 | onChange={onChange} |
| 61 | onBJIDSubmit={onBJIDSubmit} | 68 | onBJIDSubmit={onBJIDSubmit} |
| 62 | onSyncBJIDSubmit={onSyncBJIDSubmit} | 69 | onSyncBJIDSubmit={onSyncBJIDSubmit} |
| 70 | + onSlackURLSubmit={onSlackURLSubmit} | ||
| 63 | profile={profile} | 71 | profile={profile} |
| 64 | ></SettingForm> | 72 | ></SettingForm> |
| 65 | ); | 73 | ); | ... | ... |
| ... | @@ -5,7 +5,8 @@ export const setBJID = ({ username, userBJID }) => | ... | @@ -5,7 +5,8 @@ export const setBJID = ({ username, userBJID }) => |
| 5 | username: username, | 5 | username: username, |
| 6 | userBJID: userBJID, | 6 | userBJID: userBJID, |
| 7 | }); | 7 | }); |
| 8 | - | 8 | +export const setPROFILE = (postdata) => |
| 9 | + client.post('api/profile/setprofile', postdata); | ||
| 9 | export const getPROFILE = ({ username }) => | 10 | export const getPROFILE = ({ username }) => |
| 10 | client.post('api/profile/getprofile', { username }); | 11 | client.post('api/profile/getprofile', { username }); |
| 11 | 12 | ... | ... |
| 1 | -/* | ||
| 2 | -1. 날짜 순 정렬 | ||
| 3 | -2. 현재 날짜와의 차이 | ||
| 4 | -3. 최근 일주일간 푼 문제 수 | ||
| 5 | -4. 추천 문제 | ||
| 6 | -*/ | ||
| 7 | -exports.analyzeBJ = function (solvedBJ) { | ||
| 8 | - console.log(typeof solvedBJ); | ||
| 9 | - if (solvedBJ) { | ||
| 10 | - solvedBJ.sort(function (a, b) { | ||
| 11 | - return a.solvedDate > b.solvedDate | ||
| 12 | - ? -1 | ||
| 13 | - : a.solvedDate < b.solvedDate | ||
| 14 | - ? 1 | ||
| 15 | - : 0; | ||
| 16 | - }); | ||
| 17 | - console.log(solvedBJ); | ||
| 18 | - } | ||
| 19 | -}; |
| ... | @@ -12,6 +12,11 @@ const [SET_BJID, SET_BJID_SUCCESS, SET_BJID_FAILURE] = createRequestActionTypes( | ... | @@ -12,6 +12,11 @@ const [SET_BJID, SET_BJID_SUCCESS, SET_BJID_FAILURE] = createRequestActionTypes( |
| 12 | 'profile/SET_BJID', | 12 | 'profile/SET_BJID', |
| 13 | ); | 13 | ); |
| 14 | const [ | 14 | const [ |
| 15 | + SET_SLACK, | ||
| 16 | + SET_SLACK_SUCCESS, | ||
| 17 | + SET_SLACK_FAILURE, | ||
| 18 | +] = createRequestActionTypes('/profile/SET_SLACK'); | ||
| 19 | +const [ | ||
| 15 | GET_PROFILE, | 20 | GET_PROFILE, |
| 16 | GET_PROFILE_SUCCESS, | 21 | GET_PROFILE_SUCCESS, |
| 17 | GET_PROFILE_FAILURE, | 22 | GET_PROFILE_FAILURE, |
| ... | @@ -26,6 +31,13 @@ export const initializeProfile = createAction(INITIALIZE); | ... | @@ -26,6 +31,13 @@ export const initializeProfile = createAction(INITIALIZE); |
| 26 | export const syncBJID = createAction(SYNC_BJID, ({ username }) => ({ | 31 | export const syncBJID = createAction(SYNC_BJID, ({ username }) => ({ |
| 27 | username, | 32 | username, |
| 28 | })); | 33 | })); |
| 34 | +export const setSLACK = createAction( | ||
| 35 | + SET_SLACK, | ||
| 36 | + ({ username, slackWebHookURL }) => ({ | ||
| 37 | + username, | ||
| 38 | + slackWebHookURL, | ||
| 39 | + }), | ||
| 40 | +); | ||
| 29 | export const setBJID = createAction(SET_BJID, ({ username, userBJID }) => ({ | 41 | export const setBJID = createAction(SET_BJID, ({ username, userBJID }) => ({ |
| 30 | username, | 42 | username, |
| 31 | userBJID, | 43 | userBJID, |
| ... | @@ -45,14 +57,17 @@ const initialState = { | ... | @@ -45,14 +57,17 @@ const initialState = { |
| 45 | solvedBJ: '', | 57 | solvedBJ: '', |
| 46 | friendList: [], | 58 | friendList: [], |
| 47 | profileError: '', | 59 | profileError: '', |
| 60 | + slackWebHookURL: '', | ||
| 48 | }; | 61 | }; |
| 49 | const getPROFILESaga = createRequestSaga(GET_PROFILE, profileAPI.getPROFILE); | 62 | const getPROFILESaga = createRequestSaga(GET_PROFILE, profileAPI.getPROFILE); |
| 50 | const setBJIDSaga = createRequestSaga(SET_BJID, profileAPI.setBJID); | 63 | const setBJIDSaga = createRequestSaga(SET_BJID, profileAPI.setBJID); |
| 64 | +const setSLACKSaga = createRequestSaga(SET_SLACK, profileAPI.setPROFILE); | ||
| 51 | const syncBJIDSaga = createRequestSaga(SYNC_BJID, profileAPI.syncBJ); | 65 | const syncBJIDSaga = createRequestSaga(SYNC_BJID, profileAPI.syncBJ); |
| 52 | export function* profileSaga() { | 66 | export function* profileSaga() { |
| 53 | yield takeLatest(SET_BJID, setBJIDSaga); | 67 | yield takeLatest(SET_BJID, setBJIDSaga); |
| 54 | yield takeLatest(GET_PROFILE, getPROFILESaga); | 68 | yield takeLatest(GET_PROFILE, getPROFILESaga); |
| 55 | yield takeLatest(SYNC_BJID, syncBJIDSaga); | 69 | yield takeLatest(SYNC_BJID, syncBJIDSaga); |
| 70 | + yield takeLatest(SET_SLACK, setSLACKSaga); | ||
| 56 | } | 71 | } |
| 57 | 72 | ||
| 58 | export default handleActions( | 73 | export default handleActions( |
| ... | @@ -64,7 +79,9 @@ export default handleActions( | ... | @@ -64,7 +79,9 @@ export default handleActions( |
| 64 | }), | 79 | }), |
| 65 | [GET_PROFILE_SUCCESS]: ( | 80 | [GET_PROFILE_SUCCESS]: ( |
| 66 | state, | 81 | state, |
| 67 | - { payload: { username, userBJID, solvedBJ, friendList } }, | 82 | + { |
| 83 | + payload: { username, userBJID, solvedBJ, friendList, slackWebHookURL }, | ||
| 84 | + }, | ||
| 68 | ) => ({ | 85 | ) => ({ |
| 69 | ...state, | 86 | ...state, |
| 70 | username: username, | 87 | username: username, |
| ... | @@ -72,6 +89,7 @@ export default handleActions( | ... | @@ -72,6 +89,7 @@ export default handleActions( |
| 72 | solvedBJ: solvedBJ, | 89 | solvedBJ: solvedBJ, |
| 73 | friendList: friendList, | 90 | friendList: friendList, |
| 74 | profileError: null, | 91 | profileError: null, |
| 92 | + slackWebHookURL: slackWebHookURL, | ||
| 75 | }), | 93 | }), |
| 76 | [GET_PROFILE_FAILURE]: (state, { payload: error }) => ({ | 94 | [GET_PROFILE_FAILURE]: (state, { payload: error }) => ({ |
| 77 | ...state, | 95 | ...state, |
| ... | @@ -87,6 +105,15 @@ export default handleActions( | ... | @@ -87,6 +105,15 @@ export default handleActions( |
| 87 | ...state, | 105 | ...state, |
| 88 | profileError: error, | 106 | profileError: error, |
| 89 | }), | 107 | }), |
| 108 | + [SET_SLACK_SUCCESS]: (state, { payload: { slackWebHookURL } }) => ({ | ||
| 109 | + ...state, | ||
| 110 | + slackWebHookURL: slackWebHookURL, | ||
| 111 | + profileError: null, | ||
| 112 | + }), | ||
| 113 | + [SET_SLACK_FAILURE]: (state, { payload: error }) => ({ | ||
| 114 | + ...state, | ||
| 115 | + profileError: error, | ||
| 116 | + }), | ||
| 90 | [SYNC_BJID_SUCCESS]: (state, { payload: { solvedBJ } }) => ({ | 117 | [SYNC_BJID_SUCCESS]: (state, { payload: { solvedBJ } }) => ({ |
| 91 | ...state, | 118 | ...state, |
| 92 | solvedBJ, | 119 | solvedBJ, | ... | ... |
| 1 | import React from 'react'; | 1 | import React from 'react'; |
| 2 | import HeaderContainer from '../containers/common/HeaderContainer'; | 2 | import HeaderContainer from '../containers/common/HeaderContainer'; |
| 3 | -import SettingForm from '../components/setting/SettingForm'; | ||
| 4 | import SettingContainer from '../containers/setting/SettingContainer'; | 3 | import SettingContainer from '../containers/setting/SettingContainer'; |
| 5 | 4 | ||
| 6 | const SettingPage = () => { | 5 | const SettingPage = () => { | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
jaksimsamil-server/src/data/problem_set.js
0 → 100644
| 1 | +export const problem_set = [ | ||
| 2 | + "1517", | ||
| 3 | + "2448", | ||
| 4 | + "1891", | ||
| 5 | + "1074", | ||
| 6 | + "2263", | ||
| 7 | + "1780", | ||
| 8 | + "11728", | ||
| 9 | + "10816", | ||
| 10 | + "10815", | ||
| 11 | + "2109", | ||
| 12 | + "1202", | ||
| 13 | + "1285", | ||
| 14 | + "2138", | ||
| 15 | + "1080", | ||
| 16 | + "11399", | ||
| 17 | + "1931", | ||
| 18 | + "11047", | ||
| 19 | + "15666", | ||
| 20 | + "15665", | ||
| 21 | + "15664", | ||
| 22 | + "15663", | ||
| 23 | + "15657", | ||
| 24 | + "15656", | ||
| 25 | + "15655", | ||
| 26 | + "15654", | ||
| 27 | + "15652", | ||
| 28 | + "15651", | ||
| 29 | + "15650", | ||
| 30 | + "15649", | ||
| 31 | + "6603", | ||
| 32 | + "10971", | ||
| 33 | + "10819", | ||
| 34 | + "10973", | ||
| 35 | + "10974", | ||
| 36 | + "10972", | ||
| 37 | + "7576", | ||
| 38 | + "1248", | ||
| 39 | + "2529", | ||
| 40 | + "15661", | ||
| 41 | + "14501", | ||
| 42 | + "1759", | ||
| 43 | + "14391", | ||
| 44 | + "14889", | ||
| 45 | + "1182", | ||
| 46 | + "11723", | ||
| 47 | + "1748", | ||
| 48 | + "6064", | ||
| 49 | + "1107", | ||
| 50 | + "3085", | ||
| 51 | + "2309", | ||
| 52 | + "1748", | ||
| 53 | + "14500", | ||
| 54 | + "1107", | ||
| 55 | + "1476", | ||
| 56 | + "3085", | ||
| 57 | + "2309", | ||
| 58 | + "1261", | ||
| 59 | + "13549", | ||
| 60 | + "14226", | ||
| 61 | + "13913", | ||
| 62 | + "1697", | ||
| 63 | + "1967", | ||
| 64 | + "1167", | ||
| 65 | + "11725", | ||
| 66 | + "2250", | ||
| 67 | + "1991", | ||
| 68 | + "7562", | ||
| 69 | + "2178", | ||
| 70 | + "4963", | ||
| 71 | + "2667", | ||
| 72 | + "1707", | ||
| 73 | + "11724", | ||
| 74 | + "1260", | ||
| 75 | + "13023", | ||
| 76 | + "11652", | ||
| 77 | + "1377", | ||
| 78 | + "11004", | ||
| 79 | + "10825", | ||
| 80 | + "2751", | ||
| 81 | + "9461", | ||
| 82 | + "1699", | ||
| 83 | + "9095", | ||
| 84 | + "2225", | ||
| 85 | + "2133", | ||
| 86 | + "11727", | ||
| 87 | + "11726", | ||
| 88 | + "1463", | ||
| 89 | + "2748", | ||
| 90 | + "2747", | ||
| 91 | + "11656", | ||
| 92 | + "10824", | ||
| 93 | + "2743", | ||
| 94 | + "10820", | ||
| 95 | + "10808", | ||
| 96 | + "11655", | ||
| 97 | + "11720", | ||
| 98 | + "1008", | ||
| 99 | + "10951", | ||
| 100 | + "2557", | ||
| 101 | + "1021", | ||
| 102 | + "1966", | ||
| 103 | + "2164", | ||
| 104 | + "10799", | ||
| 105 | + "17413", | ||
| 106 | + "10866", | ||
| 107 | + "1158", | ||
| 108 | + "10845", | ||
| 109 | + "1406", | ||
| 110 | + "1874", | ||
| 111 | + "9012", | ||
| 112 | + "9093", | ||
| 113 | + "10828", | ||
| 114 | + "11721", | ||
| 115 | + "11719", | ||
| 116 | + "11718", | ||
| 117 | + "10953", | ||
| 118 | + "2558", | ||
| 119 | + "10814", | ||
| 120 | + "1181", | ||
| 121 | + "11651", | ||
| 122 | + "11650", | ||
| 123 | + "1427", | ||
| 124 | + "2108", | ||
| 125 | + "10989", | ||
| 126 | + "2751", | ||
| 127 | + "2750", | ||
| 128 | + "1436", | ||
| 129 | + "1018", | ||
| 130 | + "7568", | ||
| 131 | + "2231", | ||
| 132 | + "2798", | ||
| 133 | + "1002", | ||
| 134 | + "3053", | ||
| 135 | + "4153", | ||
| 136 | + "3009", | ||
| 137 | + "1085", | ||
| 138 | + "9020", | ||
| 139 | + "4948", | ||
| 140 | + "1929", | ||
| 141 | + "2581", | ||
| 142 | + "1978", | ||
| 143 | + "2292", | ||
| 144 | + "6064", | ||
| 145 | + "2775", | ||
| 146 | + "10250", | ||
| 147 | + "2869", | ||
| 148 | + "1011", | ||
| 149 | + "1193", | ||
| 150 | + "2839", | ||
| 151 | + "1712", | ||
| 152 | + "1316", | ||
| 153 | + "2941", | ||
| 154 | + "5622", | ||
| 155 | + "2908", | ||
| 156 | + "1152", | ||
| 157 | + "1157", | ||
| 158 | + "2675", | ||
| 159 | + "10809", | ||
| 160 | + "11720", | ||
| 161 | + "11654", | ||
| 162 | + "11729", | ||
| 163 | + "2447", | ||
| 164 | + "3052", | ||
| 165 | + "10818", | ||
| 166 | + "10872", | ||
| 167 | + "10870", | ||
| 168 | + "1065", | ||
| 169 | + "4673", | ||
| 170 | + "15596", | ||
| 171 | + "4344", | ||
| 172 | + "2920", | ||
| 173 | + "8958", | ||
| 174 | + "1546", | ||
| 175 | + "2577", | ||
| 176 | + "2562", | ||
| 177 | + "1110", | ||
| 178 | + "10951", | ||
| 179 | + "10952", | ||
| 180 | + "10871", | ||
| 181 | + "2439", | ||
| 182 | + "2438", | ||
| 183 | + "11022", | ||
| 184 | + "11021", | ||
| 185 | + "2742", | ||
| 186 | + "2741", | ||
| 187 | + "15552", | ||
| 188 | + "8393", | ||
| 189 | + "10950", | ||
| 190 | + "2739", | ||
| 191 | + "10817", | ||
| 192 | + "2884", | ||
| 193 | + "2753", | ||
| 194 | + "9498", | ||
| 195 | + "1330", | ||
| 196 | + "2588", | ||
| 197 | + "10430", | ||
| 198 | + "10869", | ||
| 199 | + "1008", | ||
| 200 | + "10998", | ||
| 201 | + "7287", | ||
| 202 | + "10172", | ||
| 203 | + "10171", | ||
| 204 | + "10718", | ||
| 205 | + "1001", | ||
| 206 | + "1000", | ||
| 207 | + "2557", | ||
| 208 | +]; |
jaksimsamil-server/src/util/analyzeBJ.js
0 → 100644
| 1 | +/* | ||
| 2 | +2. 현재 날짜와의 차이 => | ||
| 3 | +3. 오늘 푼 문제 => 앞에서부터 순회하면서 데이트 같은거 찾기 | ||
| 4 | +3. 최근 일주일간 푼 문제 수 => 앞에서부터 순회하면서 - 값이 | ||
| 5 | +4. 추천 문제 => 정규 셋에서 없는거 찾기 | ||
| 6 | +5. 날짜별로 묶기. | ||
| 7 | +데이터베이스에서 처리하자 | ||
| 8 | +*/ | ||
| 9 | + | ||
| 10 | +let moment = require('moment'); | ||
| 11 | + | ||
| 12 | +exports.analyzeBJ = function (solvedBJ) { | ||
| 13 | + try { | ||
| 14 | + if (solvedBJ) { | ||
| 15 | + console.log(solvedBJ[0]); | ||
| 16 | + let presentDate = moment(); | ||
| 17 | + let presentDate_str = presentDate.format('YYYYMMDD'); | ||
| 18 | + let latestDate = moment(solvedBJ[0].solved_date, 'YYYYMMDD'); | ||
| 19 | + let difflatest = presentDate.diff(latestDate, 'days'); | ||
| 20 | + | ||
| 21 | + let solvedBJbyDATE = {}; | ||
| 22 | + for (let i = 0; i < solvedBJ.length; i++) { | ||
| 23 | + if (!(solvedBJ[i].solved_date in solvedBJbyDATE)) { | ||
| 24 | + solvedBJbyDATE[solvedBJ[i].solved_date] = []; | ||
| 25 | + solvedBJbyDATE[solvedBJ[i].solved_date].push(solvedBJ[i]); | ||
| 26 | + } else { | ||
| 27 | + solvedBJbyDATE[solvedBJ[i].solved_date].push(solvedBJ[i]); | ||
| 28 | + } | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + let latestNum = solvedBJbyDATE[solvedBJ[0].solved_date].length; | ||
| 32 | + let presentNum = | ||
| 33 | + presentDate_str in solvedBJbyDATE | ||
| 34 | + ? solvedBJbyDATE[presentDate_str].length | ||
| 35 | + : 0; | ||
| 36 | + let returnOBJ = { | ||
| 37 | + latestDate: latestDate.format('YYYYMMDD'), | ||
| 38 | + difflatest: difflatest, | ||
| 39 | + latestNum: latestNum, | ||
| 40 | + presentNum: presentNum, | ||
| 41 | + solvedBJbyDATE: solvedBJbyDATE, | ||
| 42 | + }; | ||
| 43 | + console.log(returnOBJ); | ||
| 44 | + return returnOBJ; | ||
| 45 | + } | ||
| 46 | + } catch (e) { | ||
| 47 | + console.log(e); | ||
| 48 | + } | ||
| 49 | +}; |
jaksimsamil-server/src/util/compareBJ.js
0 → 100644
| 1 | +/* | ||
| 2 | +집중을 해보자. | ||
| 3 | +새거와 데이터가 있다. | ||
| 4 | +데이터 기준으로 새거에 자료가 있으면 넘어가기 | ||
| 5 | +없으면 새 배열에 추가 | ||
| 6 | +키만 모아둔 리스트를 만들자. | ||
| 7 | +그렇게 해서 | ||
| 8 | +반복은 새거 길이만큼 | ||
| 9 | +데이터에 있으면 추가 X | ||
| 10 | +없으면 추가 | ||
| 11 | +그렇게 반환 | ||
| 12 | +*/ | ||
| 13 | + | ||
| 14 | +exports.compareBJ = function (solvedBJ_new, problem_set) { | ||
| 15 | + try { | ||
| 16 | + let new_obj = []; | ||
| 17 | + for (let i = 0; i < solvedBJ.length; i++) { | ||
| 18 | + if (solvedBJ_new[i].problem_number in problem_set) { | ||
| 19 | + new_obj.push(solvedBJ_new[i]); | ||
| 20 | + } | ||
| 21 | + } | ||
| 22 | + console.log(new_obj); | ||
| 23 | + } catch (e) { | ||
| 24 | + console.log(e); | ||
| 25 | + } | ||
| 26 | +}; |
jaksimsamil-server/src/util/test.js
0 → 100644
| 1 | +var getBJ = require("./getBJ"); | ||
| 2 | +var fs = require("fs"); | ||
| 3 | + | ||
| 4 | +let dataset = [ | ||
| 5 | + "1517", | ||
| 6 | + "2448", | ||
| 7 | + "1891", | ||
| 8 | + "1074", | ||
| 9 | + "2263", | ||
| 10 | + "1780", | ||
| 11 | + "11728", | ||
| 12 | + "10816", | ||
| 13 | + "10815", | ||
| 14 | + "2109", | ||
| 15 | + "1202", | ||
| 16 | + "1285", | ||
| 17 | + "2138", | ||
| 18 | + "1080", | ||
| 19 | + "11399", | ||
| 20 | + "1931", | ||
| 21 | + "11047", | ||
| 22 | + "15666", | ||
| 23 | + "15665", | ||
| 24 | + "15664", | ||
| 25 | + "15663", | ||
| 26 | + "15657", | ||
| 27 | + "15656", | ||
| 28 | + "15655", | ||
| 29 | + "15654", | ||
| 30 | + "15652", | ||
| 31 | + "15651", | ||
| 32 | + "15650", | ||
| 33 | + "15649", | ||
| 34 | + "6603", | ||
| 35 | + "10971", | ||
| 36 | + "10819", | ||
| 37 | + "10973", | ||
| 38 | + "10974", | ||
| 39 | + "10972", | ||
| 40 | + "7576", | ||
| 41 | + "1248", | ||
| 42 | + "2529", | ||
| 43 | + "15661", | ||
| 44 | + "14501", | ||
| 45 | + "1759", | ||
| 46 | + "14391", | ||
| 47 | + "14889", | ||
| 48 | + "1182", | ||
| 49 | + "11723", | ||
| 50 | + "1748", | ||
| 51 | + "6064", | ||
| 52 | + "1107", | ||
| 53 | + "3085", | ||
| 54 | + "2309", | ||
| 55 | + "1748", | ||
| 56 | + "14500", | ||
| 57 | + "1107", | ||
| 58 | + "1476", | ||
| 59 | + "3085", | ||
| 60 | + "2309", | ||
| 61 | + "1261", | ||
| 62 | + "13549", | ||
| 63 | + "14226", | ||
| 64 | + "13913", | ||
| 65 | + "1697", | ||
| 66 | + "1967", | ||
| 67 | + "1167", | ||
| 68 | + "11725", | ||
| 69 | + "2250", | ||
| 70 | + "1991", | ||
| 71 | + "7562", | ||
| 72 | + "2178", | ||
| 73 | + "4963", | ||
| 74 | + "2667", | ||
| 75 | + "1707", | ||
| 76 | + "11724", | ||
| 77 | + "1260", | ||
| 78 | + "13023", | ||
| 79 | + "11652", | ||
| 80 | + "1377", | ||
| 81 | + "11004", | ||
| 82 | + "10825", | ||
| 83 | + "2751", | ||
| 84 | + "9461", | ||
| 85 | + "1699", | ||
| 86 | + "9095", | ||
| 87 | + "2225", | ||
| 88 | + "2133", | ||
| 89 | + "11727", | ||
| 90 | + "11726", | ||
| 91 | + "1463", | ||
| 92 | + "2748", | ||
| 93 | + "2747", | ||
| 94 | + "11656", | ||
| 95 | + "10824", | ||
| 96 | + "2743", | ||
| 97 | + "10820", | ||
| 98 | + "10808", | ||
| 99 | + "11655", | ||
| 100 | + "11720", | ||
| 101 | + "1008", | ||
| 102 | + "10951", | ||
| 103 | + "2557", | ||
| 104 | + "1021", | ||
| 105 | + "1966", | ||
| 106 | + "2164", | ||
| 107 | + "10799", | ||
| 108 | + "17413", | ||
| 109 | + "10866", | ||
| 110 | + "1158", | ||
| 111 | + "10845", | ||
| 112 | + "1406", | ||
| 113 | + "1874", | ||
| 114 | + "9012", | ||
| 115 | + "9093", | ||
| 116 | + "10828", | ||
| 117 | + "11721", | ||
| 118 | + "11719", | ||
| 119 | + "11718", | ||
| 120 | + "10953", | ||
| 121 | + "2558", | ||
| 122 | + "10814", | ||
| 123 | + "1181", | ||
| 124 | + "11651", | ||
| 125 | + "11650", | ||
| 126 | + "1427", | ||
| 127 | + "2108", | ||
| 128 | + "10989", | ||
| 129 | + "2751", | ||
| 130 | + "2750", | ||
| 131 | + "1436", | ||
| 132 | + "1018", | ||
| 133 | + "7568", | ||
| 134 | + "2231", | ||
| 135 | + "2798", | ||
| 136 | + "1002", | ||
| 137 | + "3053", | ||
| 138 | + "4153", | ||
| 139 | + "3009", | ||
| 140 | + "1085", | ||
| 141 | + "9020", | ||
| 142 | + "4948", | ||
| 143 | + "1929", | ||
| 144 | + "2581", | ||
| 145 | + "1978", | ||
| 146 | + "2292", | ||
| 147 | + "6064", | ||
| 148 | + "2775", | ||
| 149 | + "10250", | ||
| 150 | + "2869", | ||
| 151 | + "1011", | ||
| 152 | + "1193", | ||
| 153 | + "2839", | ||
| 154 | + "1712", | ||
| 155 | + "1316", | ||
| 156 | + "2941", | ||
| 157 | + "5622", | ||
| 158 | + "2908", | ||
| 159 | + "1152", | ||
| 160 | + "1157", | ||
| 161 | + "2675", | ||
| 162 | + "10809", | ||
| 163 | + "11720", | ||
| 164 | + "11654", | ||
| 165 | + "11729", | ||
| 166 | + "2447", | ||
| 167 | + "3052", | ||
| 168 | + "10818", | ||
| 169 | + "10872", | ||
| 170 | + "10870", | ||
| 171 | + "1065", | ||
| 172 | + "4673", | ||
| 173 | + "15596", | ||
| 174 | + "4344", | ||
| 175 | + "2920", | ||
| 176 | + "8958", | ||
| 177 | + "1546", | ||
| 178 | + "2577", | ||
| 179 | + "2562", | ||
| 180 | + "1110", | ||
| 181 | + "10951", | ||
| 182 | + "10952", | ||
| 183 | + "10871", | ||
| 184 | + "2439", | ||
| 185 | + "2438", | ||
| 186 | + "11022", | ||
| 187 | + "11021", | ||
| 188 | + "2742", | ||
| 189 | + "2741", | ||
| 190 | + "15552", | ||
| 191 | + "8393", | ||
| 192 | + "10950", | ||
| 193 | + "2739", | ||
| 194 | + "10817", | ||
| 195 | + "2884", | ||
| 196 | + "2753", | ||
| 197 | + "9498", | ||
| 198 | + "1330", | ||
| 199 | + "2588", | ||
| 200 | + "10430", | ||
| 201 | + "10869", | ||
| 202 | + "1008", | ||
| 203 | + "10998", | ||
| 204 | + "7287", | ||
| 205 | + "10172", | ||
| 206 | + "10171", | ||
| 207 | + "10718", | ||
| 208 | + "1001", | ||
| 209 | + "1000", | ||
| 210 | + "2557", | ||
| 211 | +]; | ||
| 212 | + | ||
| 213 | +const test = async (userid) => { | ||
| 214 | + let lst = await getBJ.getBJ(userid); | ||
| 215 | + let return_lst = []; | ||
| 216 | + for (let i = 0; i < lst.length; i++) { | ||
| 217 | + return_lst.push(lst[i].problem_number); | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + var stringJson = JSON.stringify(return_lst) + "\n"; | ||
| 221 | + fs.open("test.json", "a", "666", function (err, id) { | ||
| 222 | + if (err) { | ||
| 223 | + console.log("file open err!!"); | ||
| 224 | + } else { | ||
| 225 | + fs.write(id, stringJson, null, "utf8", function (err) { | ||
| 226 | + console.log("file was saved!"); | ||
| 227 | + }); | ||
| 228 | + } | ||
| 229 | + }); | ||
| 230 | +}; | ||
| 231 | + | ||
| 232 | +/* | ||
| 233 | + | ||
| 234 | +*/ | ||
| 235 | +test("jwseo001"); |
jaksimsamil-server/src/util/test.json
0 → 100644
| 1 | +[ | ||
| 2 | + "1517", | ||
| 3 | + "2448", | ||
| 4 | + "1891", | ||
| 5 | + "1074", | ||
| 6 | + "2263", | ||
| 7 | + "1780", | ||
| 8 | + "11728", | ||
| 9 | + "10816", | ||
| 10 | + "10815", | ||
| 11 | + "2109", | ||
| 12 | + "1202", | ||
| 13 | + "1285", | ||
| 14 | + "2138", | ||
| 15 | + "1080", | ||
| 16 | + "11399", | ||
| 17 | + "1931", | ||
| 18 | + "11047", | ||
| 19 | + "15666", | ||
| 20 | + "15665", | ||
| 21 | + "15664", | ||
| 22 | + "15663", | ||
| 23 | + "15657", | ||
| 24 | + "15656", | ||
| 25 | + "15655", | ||
| 26 | + "15654", | ||
| 27 | + "15652", | ||
| 28 | + "15651", | ||
| 29 | + "15650", | ||
| 30 | + "15649", | ||
| 31 | + "6603", | ||
| 32 | + "10971", | ||
| 33 | + "10819", | ||
| 34 | + "10973", | ||
| 35 | + "10974", | ||
| 36 | + "10972", | ||
| 37 | + "7576", | ||
| 38 | + "1248", | ||
| 39 | + "2529", | ||
| 40 | + "15661", | ||
| 41 | + "14501", | ||
| 42 | + "1759", | ||
| 43 | + "14391", | ||
| 44 | + "14889", | ||
| 45 | + "1182", | ||
| 46 | + "11723", | ||
| 47 | + "1748", | ||
| 48 | + "6064", | ||
| 49 | + "1107", | ||
| 50 | + "3085", | ||
| 51 | + "2309", | ||
| 52 | + "1748", | ||
| 53 | + "14500", | ||
| 54 | + "1107", | ||
| 55 | + "1476", | ||
| 56 | + "3085", | ||
| 57 | + "2309", | ||
| 58 | + "1261", | ||
| 59 | + "13549", | ||
| 60 | + "14226", | ||
| 61 | + "13913", | ||
| 62 | + "1697", | ||
| 63 | + "1967", | ||
| 64 | + "1167", | ||
| 65 | + "11725", | ||
| 66 | + "2250", | ||
| 67 | + "1991", | ||
| 68 | + "7562", | ||
| 69 | + "2178", | ||
| 70 | + "4963", | ||
| 71 | + "2667", | ||
| 72 | + "1707", | ||
| 73 | + "11724", | ||
| 74 | + "1260", | ||
| 75 | + "13023", | ||
| 76 | + "11652", | ||
| 77 | + "1377", | ||
| 78 | + "11004", | ||
| 79 | + "10825", | ||
| 80 | + "2751", | ||
| 81 | + "9461", | ||
| 82 | + "1699", | ||
| 83 | + "9095", | ||
| 84 | + "2225", | ||
| 85 | + "2133", | ||
| 86 | + "11727", | ||
| 87 | + "11726", | ||
| 88 | + "1463", | ||
| 89 | + "2748", | ||
| 90 | + "2747", | ||
| 91 | + "11656", | ||
| 92 | + "10824", | ||
| 93 | + "2743", | ||
| 94 | + "10820", | ||
| 95 | + "10808", | ||
| 96 | + "11655", | ||
| 97 | + "11720", | ||
| 98 | + "1008", | ||
| 99 | + "10951", | ||
| 100 | + "2557", | ||
| 101 | + "1021", | ||
| 102 | + "1966", | ||
| 103 | + "2164", | ||
| 104 | + "10799", | ||
| 105 | + "17413", | ||
| 106 | + "10866", | ||
| 107 | + "1158", | ||
| 108 | + "10845", | ||
| 109 | + "1406", | ||
| 110 | + "1874", | ||
| 111 | + "9012", | ||
| 112 | + "9093", | ||
| 113 | + "10828", | ||
| 114 | + "11721", | ||
| 115 | + "11719", | ||
| 116 | + "11718", | ||
| 117 | + "10953", | ||
| 118 | + "2558", | ||
| 119 | + "10814", | ||
| 120 | + "1181", | ||
| 121 | + "11651", | ||
| 122 | + "11650", | ||
| 123 | + "1427", | ||
| 124 | + "2108", | ||
| 125 | + "10989", | ||
| 126 | + "2751", | ||
| 127 | + "2750", | ||
| 128 | + "1436", | ||
| 129 | + "1018", | ||
| 130 | + "7568", | ||
| 131 | + "2231", | ||
| 132 | + "2798", | ||
| 133 | + "1002", | ||
| 134 | + "3053", | ||
| 135 | + "4153", | ||
| 136 | + "3009", | ||
| 137 | + "1085", | ||
| 138 | + "9020", | ||
| 139 | + "4948", | ||
| 140 | + "1929", | ||
| 141 | + "2581", | ||
| 142 | + "1978", | ||
| 143 | + "2292", | ||
| 144 | + "6064", | ||
| 145 | + "2775", | ||
| 146 | + "10250", | ||
| 147 | + "2869", | ||
| 148 | + "1011", | ||
| 149 | + "1193", | ||
| 150 | + "2839", | ||
| 151 | + "1712", | ||
| 152 | + "1316", | ||
| 153 | + "2941", | ||
| 154 | + "5622", | ||
| 155 | + "2908", | ||
| 156 | + "1152", | ||
| 157 | + "1157", | ||
| 158 | + "2675", | ||
| 159 | + "10809", | ||
| 160 | + "11720", | ||
| 161 | + "11654", | ||
| 162 | + "11729", | ||
| 163 | + "2447", | ||
| 164 | + "3052", | ||
| 165 | + "10818", | ||
| 166 | + "10872", | ||
| 167 | + "10870", | ||
| 168 | + "1065", | ||
| 169 | + "4673", | ||
| 170 | + "15596", | ||
| 171 | + "4344", | ||
| 172 | + "2920", | ||
| 173 | + "8958", | ||
| 174 | + "1546", | ||
| 175 | + "2577", | ||
| 176 | + "2562", | ||
| 177 | + "1110", | ||
| 178 | + "10951", | ||
| 179 | + "10952", | ||
| 180 | + "10871", | ||
| 181 | + "2439", | ||
| 182 | + "2438", | ||
| 183 | + "11022", | ||
| 184 | + "11021", | ||
| 185 | + "2742", | ||
| 186 | + "2741", | ||
| 187 | + "15552", | ||
| 188 | + "8393", | ||
| 189 | + "10950", | ||
| 190 | + "2739", | ||
| 191 | + "10817", | ||
| 192 | + "2884", | ||
| 193 | + "2753", | ||
| 194 | + "9498", | ||
| 195 | + "1330", | ||
| 196 | + "2588", | ||
| 197 | + "10430", | ||
| 198 | + "10869", | ||
| 199 | + "1008", | ||
| 200 | + "10998", | ||
| 201 | + "7287", | ||
| 202 | + "10172", | ||
| 203 | + "10171", | ||
| 204 | + "10718", | ||
| 205 | + "1001", | ||
| 206 | + "1000", | ||
| 207 | + "2557" | ||
| 208 | +] |
-
Please register or login to post a comment