Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
h3mmy committed Mar 12, 2024
2 parents bf7bc42 + 1693b92 commit 938315e
Show file tree
Hide file tree
Showing 20 changed files with 146 additions and 367 deletions.
3 changes: 1 addition & 2 deletions .ci/ct/ct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ target-branch: main

helm-extra-args: --timeout 600s

chart-dirs:
- charts/bloopyboi
chart-dirs: []

chart-repos:
- h3mmy=https://h3mmy.github.io/helm-charts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-renovate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
token: "${{ steps.app-token.outputs.token }}"

- name: Renovate
uses: renovatebot/github-action@v40.1.3
uses: renovatebot/github-action@v40.1.4
env:
LOG_LEVEL: ${{ inputs.renovateLogLevel }}
RENOVATE_DRY_RUN: ${{ inputs.dryRun }}
Expand Down
12 changes: 6 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ stages:

docker_build:
# Use the official docker image.
image: docker:latest@sha256:0d70c541ee98e66b8f7ece8c0e9f7910732466e337a9087c2ac2868ef0775092
image: docker:latest@sha256:0b0e8cab617d83dd041d950827dc67e18db5a0c3786d660bab002120b09a6d91
stage: build
services:
- docker:dind@sha256:305e9247aea279651f13ef0119510b74d75122a629206363e370749feae94e28
- docker:dind@sha256:0b0e8cab617d83dd041d950827dc67e18db5a0c3786d660bab002120b09a6d91
before_script:
- !reference [.docker, before_script]
script:
Expand Down Expand Up @@ -79,9 +79,9 @@ docker_build:

# Tags only the $CI_DEFAULT_BRANCH as latest
push_latest:
image: docker:latest@sha256:0d70c541ee98e66b8f7ece8c0e9f7910732466e337a9087c2ac2868ef0775092
image: docker:latest@sha256:0b0e8cab617d83dd041d950827dc67e18db5a0c3786d660bab002120b09a6d91
services:
- docker:dind@sha256:305e9247aea279651f13ef0119510b74d75122a629206363e370749feae94e28
- docker:dind@sha256:0b0e8cab617d83dd041d950827dc67e18db5a0c3786d660bab002120b09a6d91
variables:
# Disable fresh pull of source
GIT_STRATEGY: none
Expand All @@ -98,9 +98,9 @@ push_latest:
- docker push $CI_REGISTRY_IMAGE:latest

push_tag:
image: docker:latest@sha256:0d70c541ee98e66b8f7ece8c0e9f7910732466e337a9087c2ac2868ef0775092
image: docker:latest@sha256:0b0e8cab617d83dd041d950827dc67e18db5a0c3786d660bab002120b09a6d91
services:
- docker:dind@sha256:305e9247aea279651f13ef0119510b74d75122a629206363e370749feae94e28
- docker:dind@sha256:0b0e8cab617d83dd041d950827dc67e18db5a0c3786d660bab002120b09a6d91
variables:
GIT_STRATEGY: none
stage: push
Expand Down
2 changes: 1 addition & 1 deletion bot/providers/inspiro_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func GetInspiroService() *services.InspiroService {
}

func GetInspiroServiceWithConfig(config *services.InspiroConfig) *services.InspiroService {
return services.NewInspiroHttpClient(InspiroClientWithConfig(config))
return services.NewInspiroService(InspiroClientWithConfig(config))
}

func InspiroClientWithConfig(config *services.InspiroConfig) *services.InspiroClient {
Expand Down
2 changes: 1 addition & 1 deletion bot/services/inspiro_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type InspiroService struct {
}

// Creates New InspiroService with specified Service
func NewInspiroHttpClient(inspiro *InspiroClient) *InspiroService {
func NewInspiroService(inspiro *InspiroClient) *InspiroService {
lgr := log.NewZapLogger().With(zapcore.Field{
Key: ServiceLoggerFieldKey,
Type: zapcore.StringType,
Expand Down
4 changes: 2 additions & 2 deletions bot/services/inspiro_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestNewInspiroService(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewInspiroHttpClient(tt.args.inspiro); !reflect.DeepEqual(got.inspiroClient, tt.want.inspiroClient) {
if got := NewInspiroService(tt.args.inspiro); !reflect.DeepEqual(got.inspiroClient, tt.want.inspiroClient) {
t.Errorf("NewBloopyHttpClient() = %v, want %v", got.inspiroClient, tt.want.inspiroClient)
}
})
Expand All @@ -54,7 +54,7 @@ func TestGetsClient(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewInspiroHttpClient(tt.args.inspiro).GetClient(); !reflect.DeepEqual(got, tt.want) {
if got := NewInspiroService(tt.args.inspiro).GetClient(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewBloopyClient().GetService() = %v, want %v", got, tt.want)
}
})
Expand Down
76 changes: 66 additions & 10 deletions bot/services/media_service.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,84 @@
package services

import (
overseerr_go "github.com/devopsarr/overseerr-go/overseerr"
"context"
"fmt"

"github.com/h3mmy/bloopyboi/bot/internal/database"
"github.com/h3mmy/bloopyboi/bot/internal/log"
"github.com/h3mmy/bloopyboi/bot/internal/models"
"github.com/h3mmy/bloopyboi/ent"
"github.com/h3mmy/bloopyboi/ent/discorduser"
"github.com/h3mmy/bloopyboi/ent/mediarequest"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

type MediaService struct {
bloopyMeta models.BloopyMeta
logger *zap.Logger
overseerrClient *overseerr_go.APIClient
bookService *BookService
bloopyMeta models.BloopyMeta
logger *zap.Logger
overseerrService *OverseerrService
bookService *BookService
db *ent.Client
dbEnabled bool
}

func NewMediaService(overseerrGen *OverseerrClientGenerator, bookService *BookService) *MediaService {
func NewMediaService() *MediaService {
lgr := log.NewZapLogger().With(
zapcore.Field{Type: zapcore.StringType, Key: ServiceLoggerFieldKey, String: "media_service"},
)
return &MediaService{
bloopyMeta: models.NewBloopyMeta(),
logger: lgr,
overseerrClient: overseerrGen.generateClient(),
bookService: bookService,
bloopyMeta: models.NewBloopyMeta(),
logger: lgr,
overseerrService: nil,
bookService: nil,
dbEnabled: false,
db: nil,
}
}

func (s *MediaService) WithBookService(bsvc *BookService) {
s.bookService = bsvc
}

func (s *MediaService) WithOverseerrService(osvc *OverseerrService) {
s.overseerrService = osvc
}

func (s *MediaService) RefreshDBConnection() error {
if s.dbEnabled {
s.db.Close()
}
dbEnabled := true
dbClient, err := database.Open()
if err != nil {
s.logger.Error("failed to open database", zap.Error(err))
dbEnabled = false
}
s.db = dbClient
s.dbEnabled = dbEnabled

return err
}

func (s *MediaService) GetMediaRequestsForUser(ctx context.Context, discordUserId int) ([]*ent.MediaRequest, error) {
// TODO: Create composite request response??

if s.dbEnabled {
requests, err := s.db.MediaRequest.
Query().
WithBook().
Where(
mediarequest.HasDiscordUsersWith(
discorduser.DiscordidEQ(string(discordUserId)),

Check failure on line 73 in bot/services/media_service.go

View workflow job for this annotation

GitHub Actions / lint

stringintconv: conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?) (govet)

Check failure on line 73 in bot/services/media_service.go

View workflow job for this annotation

GitHub Actions / tests

conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)

Check failure on line 73 in bot/services/media_service.go

View workflow job for this annotation

GitHub Actions / lint

stringintconv: conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?) (govet)

Check failure on line 73 in bot/services/media_service.go

View workflow job for this annotation

GitHub Actions / tests

conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
),
).
All(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get book requests for discord user %s: %w", discordUserId, err)

Check failure on line 78 in bot/services/media_service.go

View workflow job for this annotation

GitHub Actions / lint

printf: fmt.Errorf format %s has arg discordUserId of wrong type int (govet)

Check failure on line 78 in bot/services/media_service.go

View workflow job for this annotation

GitHub Actions / tests

fmt.Errorf format %s has arg discordUserId of wrong type int

Check failure on line 78 in bot/services/media_service.go

View workflow job for this annotation

GitHub Actions / lint

printf: fmt.Errorf format %s has arg discordUserId of wrong type int (govet)

Check failure on line 78 in bot/services/media_service.go

View workflow job for this annotation

GitHub Actions / tests

fmt.Errorf format %s has arg discordUserId of wrong type int
}
return requests, nil
}
s.logger.Warn("database not enabled")
return nil, nil
}
26 changes: 0 additions & 26 deletions charts/bloopyboi/.helmignore

This file was deleted.

6 changes: 0 additions & 6 deletions charts/bloopyboi/Chart.lock

This file was deleted.

22 changes: 0 additions & 22 deletions charts/bloopyboi/Chart.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions charts/bloopyboi/README.md.gotmpl

This file was deleted.

Binary file removed charts/bloopyboi/charts/common-4.5.2.tgz
Binary file not shown.
1 change: 0 additions & 1 deletion charts/bloopyboi/templates/NOTES.txt

This file was deleted.

14 changes: 0 additions & 14 deletions charts/bloopyboi/templates/common.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions charts/bloopyboi/templates/configmap.yaml

This file was deleted.

30 changes: 0 additions & 30 deletions charts/bloopyboi/templates/rbac.yaml

This file was deleted.

Loading

0 comments on commit 938315e

Please sign in to comment.