Toggle navigation
Toggle navigation
This project
Loading...
Sign in
송용우
/
oss-Jaksimsamil
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
송용우
2020-08-21 18:02:28 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
7670f2334aa7271b0ca198241d436dd47c1e4b90
7670f233
2 parents
2cd393eb
42919eb6
Merge commit '
42919eb6
' into feature/rest_api
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
70 deletions
jaksimsamil-server/src/models/challenge.js
jaksimsamil-server/src/models/group.js
jaksimsamil-server/src/models/participation.js
jaksimsamil-server/src/models/problem.js
jaksimsamil-server/src/models/profile.js
jaksimsamil-server/src/models/session.js
jaksimsamil-server/src/models/user.js
jaksimsamil-server/src/models/challenge.js
View file @
7670f23
...
...
@@ -2,34 +2,24 @@ const mongoose = require("mongoose");
const
{
Schema
}
=
mongoose
;
const
GroupSchema
=
new
Schema
({
members
:
{
type
:
[
String
]
},
});
const
ChallengeSchema
=
new
Schema
({
challengeName
:
{
type
:
String
,
required
:
true
},
startDate
:
{
type
:
Object
,
required
:
true
},
endDate
:
{
type
:
Object
,
required
:
true
},
durationPerSession
:
{
type
:
String
,
required
:
true
},
// '1d' means one day per session, '2w' means 2 weeks per session, '3m' means 3 months per session.
goalPerSession
:
{
type
:
Number
,
required
:
true
},
// number of problems for one session
groups
:
{
type
:
[
GroupSchema
],
required
:
true
},
// groups attending challenge, group of only one member supposed to be single
});
const
ChallengeSchema
=
new
Schema
(
{
challengeName
:
{
type
:
String
,
required
:
true
},
startDate
:
{
type
:
Object
,
required
:
true
},
endDate
:
{
type
:
Object
,
required
:
true
},
durationPerSession
:
{
type
:
String
,
required
:
true
},
// '1d' means one day per session, '2w' means 2 weeks per session, '3m' means 3 months per session.
goalPerSession
:
{
type
:
Number
,
required
:
true
},
// number of problems for one session
isOpen
:
{
type
:
Boolean
},
},
{
collection
:
"challenge"
,
}
);
ChallengeSchema
.
statics
.
findByChallengeName
=
function
(
challengeName
)
{
return
this
.
findOne
({
challengeName
:
challengeName
});
};
ChallengeSchema
.
methods
.
addNewGroup
=
function
(
group
)
{
this
.
groups
.
push
(
group
);
return
this
.
save
();
};
ChallengeSchema
.
methods
.
removeGroup
=
function
(
group_id
)
{
const
idx
=
this
.
groups
.
findIndex
((
item
)
=>
item
.
_id
===
group_id
);
this
.
groups
.
splice
(
idx
,
1
);
return
this
.
save
();
};
ChallengeSchema
.
methods
.
getChallengeName
=
function
()
{
return
this
.
challengeName
;
};
...
...
@@ -50,10 +40,6 @@ ChallengeSchema.methods.getGoalPerSession = function () {
return
this
.
goalPerSession
;
};
ChallengeSchema
.
methods
.
getGroups
=
function
()
{
return
this
.
groups
;
};
ChallengeSchema
.
methods
.
serialize
=
function
()
{
return
this
.
toJSON
();
};
...
...
jaksimsamil-server/src/models/group.js
0 → 100644
View file @
7670f23
const
mongoose
=
require
(
"mongoose"
);
const
{
Schema
}
=
mongoose
;
const
GroupSchema
=
new
Schema
({
members
:
[{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'User'
}]
},{
collection
:
'group'
});
const
Group
=
mongoose
.
model
(
'Group'
,
GroupSchema
);
module
.
exports
=
Group
;
\ No newline at end of file
jaksimsamil-server/src/models/participation.js
0 → 100644
View file @
7670f23
const
mongoose
=
require
(
"mongoose"
);
const
{
Schema
}
=
mongoose
;
const
ParticipationSchema
=
new
Schema
({
sessionId
:
{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'Session'
},
groupId
:
{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'Group'
}
},{
collection
:
'particiaption'
});
const
Participation
=
mongoose
.
model
(
'Participation'
,
ParticipationSchema
);
module
.
exports
=
Participation
;
\ No newline at end of file
jaksimsamil-server/src/models/problem.js
View file @
7670f23
...
...
@@ -10,6 +10,8 @@ const ProblemSchema=new Schema({
correctNum
:
{
type
:
Number
,
required
:
true
},
count
:
{
type
:
Number
},
category
:
{
type
:[
String
]}
},{
collection
:
'problem'
});
ProblemSchema
.
statics
.
findByProblemNum
=
function
(
problemNum
){
...
...
@@ -59,5 +61,5 @@ ProblemSchema.methods.serialize=function(){
return
this
.
toJSON
();
}
const
Problem
=
mongoose
.
model
(
'Problem'
,
ProblemSchema
);
module
.
exports
=
Problem
;
\ No newline at end of file
const
Problem
=
mongoose
.
model
(
'Problem'
,
ProblemSchema
);
module
.
exports
=
Problem
;
\ No newline at end of file
...
...
jaksimsamil-server/src/models/profile.js
deleted
100644 → 0
View file @
2cd393e
const
mongoose
=
require
(
"mongoose"
);
const
{
Schema
}
=
mongoose
;
const
ProfileSchema
=
new
Schema
({
username
:
{
type
:
String
,
required
:
true
,
unique
:
true
},
userBJID
:
String
,
solvedBJ
:
Object
,
solvedBJ_date
:
Object
,
friendList
:
[
String
],
slackWebHookURL
:
String
,
goalNum
:
Number
,
});
ProfileSchema
.
statics
.
findByUsername
=
function
(
username
)
{
return
this
.
findOne
({
username
});
};
ProfileSchema
.
methods
.
getBJID
=
function
()
{
return
this
.
userBJID
;
};
ProfileSchema
.
methods
.
getBJdata
=
function
()
{
return
this
.
solvedBJ
;
};
ProfileSchema
.
methods
.
getslackURL
=
function
()
{
return
this
.
slackWebHookURL
;
};
ProfileSchema
.
methods
.
getgoalNum
=
function
()
{
return
this
.
goalNum
;
};
ProfileSchema
.
methods
.
getTodaySovled
=
function
()
{
if
(
this
.
solvedBJ_date
)
{
return
this
.
solvedBJ_date
.
presentNum
;
}
};
ProfileSchema
.
methods
.
serialize
=
function
()
{
const
data
=
this
.
toJSON
();
return
data
;
};
const
Profile
=
mongoose
.
model
(
"Profile"
,
ProfileSchema
);
module
.
exports
=
Profile
;
jaksimsamil-server/src/models/session.js
0 → 100644
View file @
7670f23
const
mongoose
=
require
(
"mongoose"
);
const
{
Schema
}
=
mongoose
;
const
SessionSchema
=
new
Schema
({
challengeId
:
{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'Challenge'
},
sessionStartDate
:
{
type
:
Object
},
sessionEndDate
:
{
type
:
Object
},
isOpen
:
{
type
:
Boolean
}
},{
collection
:
'session'
});
const
Session
=
mongoose
.
model
(
'Session'
,
SessionSchema
);
module
.
exports
=
Session
;
\ No newline at end of file
jaksimsamil-server/src/models/user.js
View file @
7670f23
...
...
@@ -10,9 +10,11 @@ const UserSchema = new Schema({
userBJID
:
String
,
sovledBJ
:
Object
,
solvedBJ_date
:
Object
,
friendList
:
[
String
],
friendList
:
[
{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'User'
}
],
slackWebHookURL
:
String
,
goalNum
:
Number
,
},{
collection
:
'user'
});
UserSchema
.
statics
.
findByUsername
=
function
(
username
)
{
...
...
Please
register
or
login
to post a comment