Skip to content

Commit

Permalink
fixed a few typos, added more observers, github actions, added mock
Browse files Browse the repository at this point in the history
  • Loading branch information
smeggmann99 committed Oct 19, 2024
1 parent f769127 commit 1fe852a
Show file tree
Hide file tree
Showing 24 changed files with 21,364 additions and 265 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: GoSec

on:
push:
branches:
- tests
pull_request:
branches:
- tests

jobs:
tests:
name: Run GoSec Security Scan
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22.3'

- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: ./...
17 changes: 16 additions & 1 deletion api/v1/handlers/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
package handlers

import (
"fmt"
"net/http"
"strconv"

"smuggr.xyz/optivum-bsf/core/datastore"
"smuggr.xyz/optivum-bsf/core/scraper"

"github.com/gin-gonic/gin"
)
Expand Down Expand Up @@ -37,6 +39,11 @@ func GetDivisionHandler(c *gin.Context) {
Respond(c, division)
}

func GetDivisionsHandler(c *gin.Context) {
fmt.Println(scraper.DivisionsDesignators)
Respond(c, scraper.DivisionsDesignators)
}

func GetTeacherHandler(c *gin.Context) {
index, err := strconv.Atoi(c.Param("index"))
if err != nil {
Expand Down Expand Up @@ -64,6 +71,10 @@ func GetTeacherHandler(c *gin.Context) {
Respond(c, teacher)
}

func GetTeachersHandler(c *gin.Context) {
Respond(c, scraper.TeachersDesignators)
}

func GetRoomHandler(c *gin.Context) {
index, err := strconv.Atoi(c.Param("index"))
if err != nil {
Expand All @@ -89,4 +100,8 @@ func GetRoomHandler(c *gin.Context) {
}

Respond(c, room)
}
}

func GetRoomsHandler(c *gin.Context) {
Respond(c, scraper.RoomsDesignators)
}
8 changes: 4 additions & 4 deletions api/v1/routes/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ func SetupScheduleRoutes(router *gin.Engine, rootGroup *gin.RouterGroup) {
{
divisionGroup.GET("/:index", handlers.GetDivisionHandler)
}
divisionsGroup := rootGroup.Group("/divisions")
divisionsGroup := rootGroup.Group("/divisions", handlers.GetDivisionsHandler)
{
divisionsGroup.GET("/")
divisionsGroup.GET("/", handlers.GetDivisionsHandler)
}

teacherGroup := rootGroup.Group("/teacher")
Expand All @@ -23,7 +23,7 @@ func SetupScheduleRoutes(router *gin.Engine, rootGroup *gin.RouterGroup) {
}
teachersGroup := rootGroup.Group("/teachers")
{
teachersGroup.GET("/")
teachersGroup.GET("/", handlers.GetTeachersHandler)
}

roomGroup := rootGroup.Group("/room")
Expand All @@ -32,6 +32,6 @@ func SetupScheduleRoutes(router *gin.Engine, rootGroup *gin.RouterGroup) {
}
roomsGroup := rootGroup.Group("/rooms")
{
roomsGroup.GET("/")
roomsGroup.GET("/", handlers.GetRoomsHandler)
}
}
10 changes: 5 additions & 5 deletions app/_config → app/config
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"scraper": {
"base_url": "http://localhost:3000/",
"base_url": "https://zsem.edu.pl/plany/",
"endpoints" : {
"division": "o%d.html",
"teacher": "n%d.html",
"room": "s%d.html",
"division": "plany/o%d.html",
"teacher": "plany/n%d.html",
"room": "plany/s%d.html",
"divisions_list": "lll.php",
"teachers_list": "nnn.php",
"rooms_list": "sss.php"
Expand All @@ -16,7 +16,7 @@
}
},
"api": {
"port": 3001,
"port": 3000,
"open_weather": {
"base_url": "https://api.openweathermap.org/data/2.5/",
"endpoints": {
Expand Down
10 changes: 5 additions & 5 deletions app/config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"scraper": {
"base_url": "https://zsem.edu.pl/plany/",
"base_url": "http://localhost:3000/",
"endpoints" : {
"division": "plany/o%d.html",
"teacher": "plany/n%d.html",
"room": "plany/s%d.html",
"division": "o%d.html",
"teacher": "n%d.html",
"room": "s%d.html",
"divisions_list": "lll.php",
"teachers_list": "nnn.php",
"rooms_list": "sss.php"
Expand All @@ -16,7 +16,7 @@
}
},
"api": {
"port": 3000,
"port": 3001,
"open_weather": {
"base_url": "https://api.openweathermap.org/data/2.5/",
"endpoints": {
Expand Down
Loading

0 comments on commit 1fe852a

Please sign in to comment.