• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

michaelcoll / quiz-app / 17788400039

17 Sep 2025 06:08AM UTC coverage: 16.191%. Remained the same
17788400039

Pull #781

github

michaelcoll
fix(herders): fix headers update

- update pnpm version
- dedupe dependencies
- fix syntax error
- rollback node dependencies to 1.4.6
Pull Request #781: fix(herders): fix headers update

0 of 3 new or added lines in 3 files covered. (0.0%)

454 of 2804 relevant lines covered (16.19%)

1.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/internal/back/infrastructure/classRepositoryImpl.go
1
/*
2
 * Copyright (c) 2023-2025 Michaƫl COLL.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package infrastructure
18

19
import (
20
        "context"
21

22
        "github.com/google/uuid"
23

24
        "github.com/michaelcoll/quiz-app/internal/back/domain"
25
        "github.com/michaelcoll/quiz-app/internal/back/infrastructure/sqlc"
26
)
27

28
type ClassDBRepository struct {
29
        domain.ClassRepository
30

31
        w *ConnectionWrapper
32
}
33

34
func NewClassRepository(w *ConnectionWrapper) *ClassDBRepository {
×
35
        return &ClassDBRepository{w: w}
×
36
}
×
37

38
func (r *ClassDBRepository) FindAll(ctx context.Context, limit uint16, offset uint16) ([]*domain.Class, error) {
×
39
        classes, err := r.w.queries().FindAllClasses(ctx, sqlc.FindAllClassesParams{
×
40
                Limit:  int64(limit),
×
41
                Offset: int64(offset),
×
42
        })
×
43
        if err != nil {
×
44
                return nil, err
×
45
        }
×
46

47
        return r.toClassArray(classes), nil
×
48
}
49

50
func (r *ClassDBRepository) CountAll(ctx context.Context) (uint32, error) {
×
51
        count, err := r.w.queries().CountAllClasses(ctx)
×
52
        if err != nil {
×
53
                return 0, err
×
54
        }
×
55

56
        return uint32(count), nil
×
57
}
58

59
func (r *ClassDBRepository) toClass(entity sqlc.StudentClass) *domain.Class {
×
60
        return &domain.Class{
×
61
                Id:   entity.Uuid,
×
62
                Name: entity.Name,
×
63
        }
×
64
}
×
65

66
func (r *ClassDBRepository) toClassArray(entities []sqlc.StudentClass) []*domain.Class {
×
67
        domains := make([]*domain.Class, len(entities))
×
68

×
69
        for i, entity := range entities {
×
70
                domains[i] = r.toClass(entity)
×
71
        }
×
72

73
        return domains
×
74
}
75

76
func (r *ClassDBRepository) CreateOrReplace(ctx context.Context, class *domain.Class) error {
×
77
        return r.w.queries().CreateOrReplaceClass(ctx, sqlc.CreateOrReplaceClassParams{
×
78
                Uuid: class.Id,
×
79
                Name: class.Name,
×
80
        })
×
81
}
×
82

83
func (r *ClassDBRepository) Delete(ctx context.Context, classId uuid.UUID) error {
×
84
        return r.w.queries().DeleteClassById(ctx, classId)
×
85
}
×
86

87
func (r *ClassDBRepository) ExistsById(ctx context.Context, classId uuid.UUID) bool {
×
88
        count, err := r.w.queries().CountClassById(ctx, classId)
×
89
        if err != nil {
×
90
                return false
×
91
        }
×
92

93
        return count == 1
×
94
}
95

96
func (r *ClassDBRepository) CreateQuizClassVisibility(ctx context.Context, quizSha1 string, classId uuid.UUID) error {
×
97
        err := r.w.queries().CreateQuizClassVisibility(ctx, sqlc.CreateQuizClassVisibilityParams{
×
98
                ClassUuid: classId,
×
99
                QuizSha1:  quizSha1,
×
100
        })
×
101
        if err != nil {
×
102
                if err.Error() == "FOREIGN KEY constraint failed" {
×
NEW
103
                        return domain.Errorf(domain.InvalidArgument, "%s", err.Error())
×
104
                }
×
105
                return err
×
106
        }
107

108
        return nil
×
109
}
110

111
func (r *ClassDBRepository) DeleteQuizClassVisibility(ctx context.Context, quizSha1 string, classId uuid.UUID) error {
×
112
        return r.w.queries().DeleteQuizClassVisibility(ctx, sqlc.DeleteQuizClassVisibilityParams{
×
113
                ClassUuid: classId,
×
114
                QuizSha1:  quizSha1,
×
115
        })
×
116
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc