-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webcal): add the webcal format type return
- Loading branch information
1 parent
c436411
commit f0912e8
Showing
10 changed files
with
177 additions
and
17 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ services: | |
- persistent-app-volume:/app | ||
ports: | ||
- "8080:8080" | ||
- "6060:6060" | ||
env_file: | ||
- .env.dev | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
FROM golang:1.22.4 as build | ||
ARG VERSION | ||
WORKDIR /app | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
RUN go install github.com/swaggo/swag/cmd/swag@latest | ||
COPY . . | ||
RUN swag init -d ./internal/api/routers,./ -g main_router.go | ||
# Debug mode | ||
RUN CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@latest | ||
RUN CGO_ENABLED=0 GOOS=linux go build -o /app/chabo-api -gcflags "all=-N -l" -ldflags="-X github.com/vareversat/chabo-api/internal/api/routers.version=$VERSION" | ||
|
||
CMD [ "/go/bin/dlv", "--listen=:4000", "--headless=true", "--log=true", "--accept-multiclient", "--api-version=2", "exec", "/app/chabo-api" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
services: | ||
app: | ||
container_name: chabo-api | ||
build: | ||
context: . | ||
dockerfile: debug.Dockerfile | ||
args: | ||
- VERSION=v0.0.0+dev | ||
volumes: | ||
- persistent-app-volume:/app | ||
ports: | ||
- "8080:8080" | ||
- "4000:4000" | ||
env_file: | ||
- .env.dev | ||
|
||
mongo: | ||
container_name: mongo-server | ||
image: mongo:6.0.16 | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: root | ||
MONGO_INITDB_ROOT_PASSWORD: my_password | ||
MONGO_INITDB_DATABASE: chabo-api | ||
|
||
volumes: | ||
persistent-app-volume: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package utils | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/vareversat/chabo-api/internal/domains" | ||
"github.com/vareversat/gics" | ||
"github.com/vareversat/gics/components" | ||
"github.com/vareversat/gics/parameters" | ||
"github.com/vareversat/gics/properties" | ||
"github.com/vareversat/gics/types" | ||
) | ||
|
||
// ComputeCalendar take all the fetched forecasts and the requested timezone | ||
// Return a gics.Calendar (webcal) | ||
func ComputeCalendar(forecasts domains.Forecasts, timezone string) (gics.Calendar, error) { | ||
calendarComponents := components.CalendarComponents{} | ||
for _, forecast := range forecasts { | ||
calendarComponents = append(calendarComponents, components.NewEventCalendarComponent( | ||
properties.NewUidProperty( | ||
forecast.ID, | ||
), | ||
properties.NewDateTimeStampProperty(time.Now().UTC()), | ||
[]components.AlarmCalendarComponent{}, | ||
properties.NewDateTimeStartProperty( | ||
forecast.CirculationClosingDate, | ||
types.WithLocalTime, | ||
parameters.NewTimeZoneIdentifierParam(timezone), | ||
), | ||
properties.NewDateTimeEndProperty( | ||
forecast.CirculationReopeningDate, | ||
types.WithLocalTime, | ||
parameters.NewTimeZoneIdentifierParam(timezone), | ||
), | ||
properties.NewDescriptionProperty(forecast.GetSummary()), | ||
properties.NewGeographicPositionProperty(44.858339101606994, -0.551626089048817), | ||
properties.NewSummaryProperty("Fermeture du pont Chaban"), | ||
properties.NewLocationProperty("Pont Jacques Chaban Delmas - Bordeaux"), | ||
)) | ||
} | ||
|
||
return gics.NewCalendar( | ||
calendarComponents, | ||
"-//Valentin REVERSAT//https://github.com/vareversat/gics//FR", | ||
"PUBLISH", | ||
"2.0", | ||
) | ||
|
||
} |