Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
holi-app-events
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
app
holi-app-events
Commits
50e68e40
Commit
50e68e40
authored
4 weeks ago
by
Gregor Schulz
Browse files
Options
Downloads
Patches
Plain Diff
improve logging
parent
804aa828
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/fetch_event.ts
+3
-5
3 additions, 5 deletions
app/fetch_event.ts
app/fetch_events.ts
+2
-2
2 additions, 2 deletions
app/fetch_events.ts
app/server.ts
+2
-1
2 additions, 1 deletion
app/server.ts
with
7 additions
and
8 deletions
app/fetch_event.ts
+
3
−
5
View file @
50e68e40
...
@@ -15,8 +15,6 @@ export type HoliEventResponse = {
...
@@ -15,8 +15,6 @@ export type HoliEventResponse = {
}
}
export
const
toHoliEvent
=
(
activity
:
Activity
):
HoliEvent
|
null
=>
{
export
const
toHoliEvent
=
(
activity
:
Activity
):
HoliEvent
|
null
=>
{
if
(
activity
.
period
.
permanent
)
return
null
return
{
return
{
id
:
activity
.
id
.
toString
(),
id
:
activity
.
id
.
toString
(),
title
:
activity
.
name
,
title
:
activity
.
name
,
...
@@ -44,10 +42,10 @@ export const fetchEvent = async (input: FetchEventInput) => {
...
@@ -44,10 +42,10 @@ export const fetchEvent = async (input: FetchEventInput) => {
const
url
=
new
URL
(
`
${
APP_API_BASE_URL
}
/activities/
${
input
.
id
}
`
)
const
url
=
new
URL
(
`
${
APP_API_BASE_URL
}
/activities/
${
input
.
id
}
`
)
const
startDate
=
Date
.
now
()
const
startDate
=
Date
.
now
()
logger
.
info
(
`fetching event from
${
url
}
`
)
logger
.
debug
(
`fetching event from
${
url
}
`
)
const
response
=
await
fetch
(
url
)
const
response
=
await
fetch
(
url
)
if
(
response
.
status
===
404
)
{
if
(
!
response
.
ok
)
{
throw
new
NotFound
(
'
Not found
'
)
throw
new
NotFound
(
'
Not found
'
)
}
}
...
@@ -70,6 +68,6 @@ export const fetchEvent = async (input: FetchEventInput) => {
...
@@ -70,6 +68,6 @@ export const fetchEvent = async (input: FetchEventInput) => {
throw
e
throw
e
}
finally
{
}
finally
{
const
duration
=
Date
.
now
()
-
startDate
const
duration
=
Date
.
now
()
-
startDate
logger
.
debug
(
`fetching event took
${
duration
}
ms`
)
logger
.
info
(
`fetching event took
${
duration
}
ms`
)
}
}
}
}
This diff is collapsed.
Click to expand it.
app/fetch_events.ts
+
2
−
2
View file @
50e68e40
...
@@ -107,7 +107,7 @@ const fetchEventsPage = async (
...
@@ -107,7 +107,7 @@ const fetchEventsPage = async (
const
startDate
=
Date
.
now
()
const
startDate
=
Date
.
now
()
logger
.
info
(
`fetching
projec
ts from
${
url
}
`
)
logger
.
debug
(
`fetching
even
ts from
${
url
}
`
)
try
{
try
{
const
response
=
await
fetch
(
url
,
{
const
response
=
await
fetch
(
url
,
{
// gregor: we don't need to send the api key to the App api
// gregor: we don't need to send the api key to the App api
...
@@ -133,7 +133,7 @@ const fetchEventsPage = async (
...
@@ -133,7 +133,7 @@ const fetchEventsPage = async (
throw
e
throw
e
}
finally
{
}
finally
{
const
duration
=
Date
.
now
()
-
startDate
const
duration
=
Date
.
now
()
-
startDate
logger
.
debug
(
`fetching projects took
${
duration
}
ms`
)
logger
.
info
(
`fetching projects took
${
duration
}
ms`
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
app/server.ts
+
2
−
1
View file @
50e68e40
...
@@ -56,6 +56,7 @@ export type EventRequest = {
...
@@ -56,6 +56,7 @@ export type EventRequest = {
}
}
const
validateEventsRequestInput
=
(
request
:
EventsRequest
):
FetchEventsInput
=>
{
const
validateEventsRequestInput
=
(
request
:
EventsRequest
):
FetchEventsInput
=>
{
logger
.
debug
(
'
validating request:
'
+
JSON
.
stringify
(
request
))
return
{
return
{
limit
:
request
.
limit
??
5
,
limit
:
request
.
limit
??
5
,
offset
:
request
.
offset
??
0
,
offset
:
request
.
offset
??
0
,
...
@@ -64,7 +65,7 @@ const validateEventsRequestInput = (request: EventsRequest): FetchEventsInput =>
...
@@ -64,7 +65,7 @@ const validateEventsRequestInput = (request: EventsRequest): FetchEventsInput =>
}
}
const
validateEventRequestInput
=
(
request
:
EventRequest
):
FetchEventInput
=>
{
const
validateEventRequestInput
=
(
request
:
EventRequest
):
FetchEventInput
=>
{
console
.
log
(
request
)
logger
.
debug
(
'
validating request:
'
+
JSON
.
stringify
(
request
)
)
return
{
return
{
id
:
request
.
id
,
id
:
request
.
id
,
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment