Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
les
gancio
Commits
f39ab70b
Verified
Commit
f39ab70b
authored
Jun 07, 2021
by
les
Browse files
improve recurrent event management
parent
a8c58e93
Changes
2
Hide whitespace changes
Inline
Side-by-side
server/api/controller/event.js
View file @
f39ab70b
...
...
@@ -544,17 +544,10 @@ const eventController = {
// get weekday
log
.
info
(
type
)
// get recurrent freq details
if
(
type
===
-
1
)
{
cursor
=
cursor
.
endOf
(
'
month
'
)
cursor
=
cursor
.
subtract
(
1
,
'
week
'
)
cursor
=
cursor
.
day
(
start_date
.
day
())
}
else
{
cursor
=
cursor
.
startOf
(
'
month
'
)
cursor
=
cursor
.
add
(
type
,
'
week
'
)
cursor
=
cursor
.
day
(
start_date
.
day
())
if
(
cursor
.
isBefore
(
dayjs
()))
{
cursor
=
cursor
.
add
(
1
,
'
month
'
)
}
cursor
=
helpers
.
getWeekdayN
(
cursor
,
type
,
start_date
.
day
())
if
(
cursor
.
isBefore
(
dayjs
()))
{
cursor
=
cursor
.
add
(
4
,
'
week
'
)
cursor
=
helpers
.
getWeekdayN
(
cursor
,
type
,
start_date
.
day
())
}
}
}
...
...
server/helpers.js
View file @
f39ab70b
...
...
@@ -135,12 +135,14 @@ module.exports = {
return
{
title
:
get
(
props
,
'
name[0]
'
,
''
),
description
:
get
(
props
,
'
description[0]
'
,
''
),
place
:
get
(
props
,
'
location[0].properties.name
'
,
''
),
address
:
get
(
props
,
'
location[0].properties.street-address
'
),
start
:
get
(
props
,
'
start[0]
'
,
''
),
end
:
get
(
props
,
'
end[0]
'
,
''
),
place
:
{
name
:
get
(
props
,
'
location[0].properties.name
'
,
''
)
||
get
(
props
,
'
location[0]
'
),
address
:
get
(
props
,
'
location[0].properties.street-address
'
)
},
start_datetime
:
dayjs
(
get
(
props
,
'
start[0]
'
,
''
)).
unix
(),
end_datetime
:
dayjs
(
get
(
props
,
'
end[0]
'
,
''
)).
unix
(),
tags
:
get
(
props
,
'
category
'
,
[]),
image
:
get
(
props
,
'
featured[0]
'
)
image
_path
:
get
(
props
,
'
featured[0]
'
)
}
})
return
res
.
json
(
events
)
...
...
@@ -160,14 +162,27 @@ module.exports = {
}
}))
}
// const event = dom.window.document.querySelected(".h-event")
// console.error(event)
// console.error(response)
}
catch
(
e
)
{
log
.
error
(
e
)
res
.
status
(
400
).
json
(
e
.
toString
)
}
},
// res.json('ok')
getWeekdayN
(
date
,
n
,
weekday
)
{
let
cursor
if
(
n
===
-
1
)
{
cursor
=
date
.
endOf
(
'
month
'
)
cursor
=
cursor
.
day
(
weekday
)
if
(
cursor
.
month
()
!==
date
.
month
())
{
cursor
=
cursor
.
subtract
(
1
,
'
week
'
)
}
}
else
{
cursor
=
date
.
startOf
(
'
month
'
)
cursor
=
cursor
.
add
(
cursor
.
day
()
<=
date
.
day
()
?
n
-
1
:
n
,
'
week
'
)
cursor
=
cursor
.
day
(
weekday
)
}
cursor
=
cursor
.
hour
(
date
.
hour
()).
minute
(
date
.
minute
()).
second
(
0
)
log
.
debug
(
cursor
)
return
cursor
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment