# HTWKalender

Scrape information about Seminar Groups and dates.

### Run Development Instance with

```bash
docker compose up --build 
```

### Go to Admin UI

➜ Webinterface: http://127.0.0.1/

➜ Admin UI: http://127.0.0.1/_/

➜ API: http://127.0.0.1/api/

For first login use the following credentials:

Email: 
```
demo@htwkalender.de
```

Password:
```
htwkalender-demo
```




### Fetch Data from HTWK

Execute the following api calls to fetch data manually from HTWK and store it in the database:

Both api calls need a token to be executed.
You can get a token by logging in to the admin ui and copy the token from the local storage.
Add this attribute to the request header of the api call:

```
Authorization : eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDE3MDA3ODQsImlkIjoicnA0Ym54YXNyczM5emR4IiwidHlwZSI6ImFkbWluIn0.j7Bt3-uaZ8CoNt8D9Oxjk7ZwvHDGZJy1xe3aq4BID3w
```

The first command will fetch all groups and store them in the database.
This should be done quick in a few seconds (0-5s).
When you execute the command again, it will update the groups in the 
database and only return new added groups.

http://127.0.0.1/api/fetch/groups

For fetching the plans, you can use the following command.
This will fetch all plans for all groups and store the events in the database.
It's done for all current existing events (ws/ss).
The whole process takes a while (30s-2min), depending on the amount of groups and events.
Stay for this time on the page and wait for the response.

http://127.0.0.1/api/fetch/events


After you fetched the events you can optional fetch sport events.
This will scrape the sport events from the HTWK website and store them in the database.
This will take a few seconds (2s-10s).

http://127.0.0.1/api/fetch/sports


### View/Filter/Search in Admin UI

If you want some easy first api endpoints and data views, you can use the Admin UI.


### Schedules

In our project we used schedules to fetch data from HTWK and store it in the database.
So they get periodically executed and keep the database up to date.

You can find the schedules in the following directory:

```
service/addSchedule.go
```

Currently, there are 3 schedules:

- FetchGroupsSchedule
- FetchEventsSchedule
- FetchSportsSchedule


## License

Calendar implementation for the HTWK Leipzig timetable. Evaluation and display of the individual dates in iCal format.
Copyright (C) 2024 HTWKalender support@htwkalender.de

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
