Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ jobs:
run:
working-directory: ./server
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v6
with:
go-version: "1.24.3"
go-version: "1.26.2"

- name: Generate GraphQL code
run: go run github.com/99designs/gqlgen generate

- name: Lint
uses: golangci/golangci-lint-action@v8
uses: golangci/golangci-lint-action@v9
with:
install-mode: "goinstall"
working-directory: ./server
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v6

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ COPY server/graph/schema.graphqls ../server/graph/schema.graphqls
RUN npm run generate
RUN npm run build

FROM golang:1.24-alpine AS server-build
FROM golang:1.26-alpine3.23 AS server-build
WORKDIR /go/src
COPY server/go.mod server/go.sum ./
RUN go mod download
Expand All @@ -17,7 +17,7 @@ RUN go run github.com/99designs/gqlgen generate
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o graphql-server server.go


FROM alpine:3.23.2 AS final
FROM alpine:3.23.4 AS final
WORKDIR /app

RUN apk add --no-cache nodejs
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions docs/docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ services:
- pgdata:/var/lib/postgresql/data

app:
build: .
image: kummerkasten:latest
image: ghcr.io/fachschaftmathphysinfo/kummerkasten:latest
env_file: .env.local
volumes:
- ./config.json:/app/config.json
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/(settings)/app-settings/footer-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function FooterForm() {
toast.success(tc("toasts.updateSuccess"))
await fetchFooterSettings();
} catch {
toast.error(tc("toasts.updateError"))
toast.error(tc("toasts.generalError"))
} finally {
setIsSaving(false);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/(settings)/faq/faq-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export default function FaqForm({qap, closeDialog}: FaqFormProps) {
{createMode ? (
<><CirclePlus/>{tc("buttons.create")}</>
) : (
<><Save/>{tc("buttons.update")}</>
<><Save/>{tc("buttons.save")}</>
)}
</Button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/(settings)/users/user-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ export default function UserForm(props: UserFormProps) {

try {
await client.request<CreateUserMutation>(CreateUserDocument, {user: newUser})
toast.success(t("toast.createSuccess"))
toast.success(tc("toasts.createSuccess"))
setHasTriedToSubmit(false)
props.refreshData()
props.closeDialog()
} catch {
toast.error(t("toast.createFailure"));
toast.error(tc("toasts.generalError"));
}
setLoading(false)
}
Expand Down
18 changes: 9 additions & 9 deletions frontend/app/(settings)/users/user-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,49 +83,49 @@ export function UserTable(props: DataTableProps) {

async function handlePromote() {
if (!dialogState.currentUser) {
toast.error(t("toast.promotionFailure"))
toast.error(tc("toasts.generalError"))
return
}

try {
await client.request<PromoteMutation>(PromoteDocument, {id: dialogState.currentUser.id})
toast.success(t("toast.promotionSuccess"))
toast.success(tc("toasts.updateSuccess"))
resetDiallogState()
props.refreshData()
} catch {
toast.error(t("toast.promotionFailure"))
toast.error(tc("toasts.generalError"))
}
}

async function handleDemote() {
if (!dialogState.currentUser) {
toast.error(t("toast.demoteFailure"))
toast.error(tc("toasts.generalError"))
return
}

try {
await client.request<DemoteMutation>(DemoteDocument, {id: dialogState.currentUser.id})
toast.success(t("toast.demoteSuccess"))
toast.success(tc("toasts.updateSuccess"))
setDialogState({mode: null, currentUser: null})
props.refreshData()
} catch {
toast.error(t("toast.demoteFailure"))
toast.error(tc("toasts.generalError"))
}
}

async function handleDelete() {
if (!dialogState.currentUser) {
toast.error(t("toast.deleteFailure"))
toast.error(tc("toasts.generalError"))
return
}

try {
await client.request<DeleteUsersMutation>(DeleteUsersDocument, {ids: [dialogState.currentUser.id]})
toast.success(t("toast.deleteSuccess"))
toast.success(tc("toasts.deleteSuccess"))
resetDiallogState()
props.refreshData()
} catch {
toast.error(t("toast.deleteFailure"))
toast.error(tc("toasts.generalError"))
}
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/app/tickets/[ticketId]/ticket-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default function TicketSidebar({selectedTicketId}: TicketSidebarProps) {
</div>
<div
className="hidden md:flex text-xs items-center text-muted-foreground min-w-[12vh] flex-shrink-0">
{t("modified")}: {ticket?.lastModified ? format(new Date(ticket.lastModified), "dd.MM.yy") : ""}
{tc("ticketSortingFields.modified")}: {ticket?.lastModified ? format(new Date(ticket.lastModified), "dd.MM.yy") : ""}
</div>
</div>
</div>
Expand Down Expand Up @@ -213,7 +213,7 @@ export default function TicketSidebar({selectedTicketId}: TicketSidebarProps) {
</div>
<div
className="hidden md:flex text-xs items-center text-muted-foreground min-w-[12vh] flex-shrink-0">
{t("modified")}: {ticket?.lastModified ? format(new Date(ticket.lastModified), "dd.MM.yy") : ""}
{tc("ticketSortingFields.modified")}: {ticket?.lastModified ? format(new Date(ticket.lastModified), "dd.MM.yy") : ""}
</div>
</div>
</div>
Expand Down
18 changes: 10 additions & 8 deletions frontend/i18n/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import {getServerClient} from "@/lib/graph/client";
export default getRequestConfig(async () => {
let locale = await getLocale()

try {
const client = getServerClient()
const data = await client.request(FrontendConfigDocument)
const configuration: Configuration[] = data.frontendConfig as Configuration[]
const defaultLanguage: StringConfiguration = configuration.find(s => s.key === "default_language") as StringConfiguration
locale = defaultLanguage.stringValue
} catch {
console.warn('could not fetch i8n config from backend, falling back on default locale')
if (!locale) {
try {
const client = getServerClient()
const data = await client.request(FrontendConfigDocument)
const configuration: Configuration[] = data.frontendConfig as Configuration[]
const defaultLanguage: StringConfiguration = configuration.find(s => s.key === "default_language") as StringConfiguration
locale = defaultLanguage.stringValue
} catch {
console.warn('could not fetch i8n config from backend, falling back on default locale')
}
}

if (!locale || locale.length == 0) locale = "de"
Expand Down
2 changes: 1 addition & 1 deletion frontend/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@
"searchbarPlaceholder": "\"{item}\" search..."
},
"buttons": {
"cancel": "Cance",
"cancel": "Cancel",
"create": "Create",
"save": "Save",
"send": "Send",
Expand Down
48 changes: 8 additions & 40 deletions server/db/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/FachschaftMathPhysInfo/kummerkasten/configuration"
"github.com/FachschaftMathPhysInfo/kummerkasten/migrations"
"github.com/FachschaftMathPhysInfo/kummerkasten/models"
"github.com/uptrace/bun"
"github.com/uptrace/bun/dialect/pgdialect"
Expand All @@ -17,21 +18,9 @@ import (
)

var (
db *bun.DB
sqldb *sql.DB
err error
tables = []interface{}{
(*models.User)(nil),
(*models.Label)(nil),
(*models.Setting)(nil),
(*models.Ticket)(nil),
(*models.QuestionAnswerPair)(nil),
(*models.Session)(nil),
}

relations = []interface{}{
(*models.LabelsToTickets)(nil),
}
db *bun.DB
sqldb *sql.DB
err error
)

const MaxDbPings = 10
Expand Down Expand Up @@ -67,34 +56,13 @@ func Init(ctx context.Context) (*sql.DB, *bun.DB) {
}

db = bun.NewDB(sqldb, pgdialect.New())
db.AddQueryHook(bundebug.NewQueryHook())
db.WithQueryHook(bundebug.NewQueryHook())
db.RegisterModel((*models.LabelsToTickets)(nil))

if err := createTables(ctx, tables); err != nil {
slog.Error("Failed to create basic tabels", "error", err)
panic("Failed to create basic tables")
}

slog.Info("Basic Database Tables successfully initialized")

if err := createTables(ctx, relations); err != nil {
slog.Error("Failed to create basic relations", "error", err)
panic("Failed to create basic relations")
if err := migrations.RunMigrations(db, ctx); err != nil {
slog.Error("Error running migrations. To save the data from corruption the service will abort.", "error", err)
panic(err)
}

slog.Info("Basic Database Relations successfully initialized")

return sqldb, db
}

func createTables(ctx context.Context, tables []interface{}) error {
for _, table := range tables {
if _, err := db.NewCreateTable().
Model(table).
IfNotExists().
Exec(ctx); err != nil {
return err
}
}
return nil
}
6 changes: 3 additions & 3 deletions server/db/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func seedTestData(ctx context.Context, db *bun.DB) error {

func removeTestUsers(ctx context.Context, db *bun.DB) error {
slog.Info("Removing test users...")
if _, err := db.NewDelete().Model((*models.User)(nil)).Where("mail IN (?)", bun.In(testEmails)).Exec(ctx); err != nil {
if _, err := db.NewDelete().Model((*models.User)(nil)).Where("mail IN (?)", bun.List(testEmails)).Exec(ctx); err != nil {
return err
}
slog.Info("Test users removed!")
Expand Down Expand Up @@ -202,7 +202,7 @@ func createSettings(ctx context.Context, db *bun.DB) error {

if err := db.NewSelect().
Model(&existing).
Where("key IN (?)", bun.In(keys)).
Where("key IN (?)", bun.List(keys)).
Scan(ctx); err != nil {
return fmt.Errorf("failed to fetch settings: %w", err)
}
Expand Down Expand Up @@ -660,7 +660,7 @@ func insertData[T any](ctx context.Context, db *bun.DB, model T, data []T, descr
if _, err := db.NewInsert().Model(&data).Exec(ctx); err != nil {
return fmt.Errorf("%s: %s", description, err)
}
slog.Info(fmt.Sprintf("%s seeded successfully\n", description))
slog.Info(fmt.Sprintf("%s seeded successfully", description))
}
return nil
}
Loading
Loading