Toggle navigation
Toggle navigation
This project
Loading...
Sign in
HyeonJun Jeon
/
Extended-Calendar
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
HyeonJun Jeon
2022-06-04 20:49:47 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3580f2dfb608db5f9abde00eca6c111d6c9229ab
3580f2df
1 parent
c2a79425
[Add] Schedule type
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
server/libs/MySQL.js
server/libs/MySQL.js
View file @
3580f2d
...
...
@@ -15,6 +15,7 @@ function jcalToSQL(jcal, userID) {
connection
.
connect
();
const
commonCols
=
[
"userID"
,
"uid"
,
"label"
,
"subjectID"
,
...
...
@@ -22,27 +23,28 @@ function jcalToSQL(jcal, userID) {
"description"
,
"url"
,
"detail"
,
"status"
,
];
const
dateScheCols
=
[...
commonCols
,
"date"
];
const
timeScheCols
=
[...
commonCols
,
"date"
,
"startTime"
,
"endTime"
];
const
dateQueryString
=
"INSERT IGNORE INTO schedules_date (
userID,
"
+
"INSERT IGNORE INTO schedules_date ("
+
dateScheCols
.
join
(
","
)
+
") VALUES ?"
;
const
timeQueryString
=
"INSERT IGNORE INTO schedules_time (
userID,
"
+
"INSERT IGNORE INTO schedules_time ("
+
timeScheCols
.
join
(
","
)
+
") VALUES ?"
;
const
dateSchedules
=
[];
const
timeSchedules
=
[];
for
(
const
sche
of
jcal
)
{
if
(
sche
.
scheType
===
"date"
)
{
dateSchedules
.
push
([
userID
,
...
dateScheCols
.
map
((
col
)
=>
sche
[
col
])]);
}
else
if
(
sche
.
scheType
===
"time"
)
{
timeSchedules
.
push
([
userID
,
...
timeScheCols
.
map
((
col
)
=>
sche
[
col
])]);
}
else
console
.
log
(
"unexpected scheType"
,
sche
);
sche
.
userID
=
userID
;
sche
.
type
=
"assignment"
;
if
(
sche
.
scheType
===
"date"
)
dateSchedules
.
push
(
dateScheCols
.
map
((
col
)
=>
sche
[
col
]));
else
if
(
sche
.
scheType
===
"time"
)
timeSchedules
.
push
(
timeScheCols
.
map
((
col
)
=>
sche
[
col
]));
else
console
.
log
(
"unexpected scheType"
,
sche
);
}
connection
.
query
(
dateQueryString
,
[
dateSchedules
],
(
error
,
result
)
=>
{
...
...
Please
register
or
login
to post a comment