-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15758cb
commit 5dd70bd
Showing
6 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package domain | ||
|
||
import ( | ||
"context" | ||
"github.com/gofrs/uuid/v5" | ||
"github.com/leighmacdonald/steamid/v4/steamid" | ||
) | ||
|
||
type VoteRepository interface { | ||
} | ||
|
||
type VoteUsecase interface { | ||
Start(ctx context.Context) | ||
} | ||
|
||
type VoteResult struct { | ||
ServerID int | ||
MatchID uuid.UUID | ||
SourceID steamid.SteamID | ||
TargetID steamid.SteamID | ||
Valid int | ||
Name string | ||
Proxy int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package votes | ||
|
||
import ( | ||
"context" | ||
"github.com/leighmacdonald/gbans/internal/database" | ||
"github.com/leighmacdonald/gbans/internal/domain" | ||
"github.com/leighmacdonald/gbans/pkg/fp" | ||
"github.com/leighmacdonald/gbans/pkg/log" | ||
"github.com/leighmacdonald/gbans/pkg/logparse" | ||
"log/slog" | ||
) | ||
|
||
type voteRepository struct { | ||
db database.Database | ||
personUsecase domain.PersonUsecase | ||
matchUsecase domain.MatchUsecase | ||
broadcaster *fp.Broadcaster[logparse.EventType, logparse.ServerEvent], | ||
} | ||
|
||
func NewVoteRepository(database database.Database, personUsecase domain.PersonUsecase, matchUsecase domain.MatchUsecase, broadcaster *fp.Broadcaster[logparse.EventType, logparse.ServerEvent]) domain.VoteRepository { | ||
return &voteRepository{ | ||
db: database, | ||
personUsecase: personUsecase, | ||
matchUsecase: matchUsecase, | ||
broadcaster: broadcaster, | ||
} | ||
} | ||
|
||
func (r voteRepository) Start(ctx context.Context) { | ||
eventChan := make(chan logparse.ServerEvent) | ||
if errRegister := r.broadcaster.Consume(eventChan, logparse.VoteDetails); errRegister != nil { | ||
slog.Warn("logWriter Tried to register duplicate reader channel", log.ErrAttr(errRegister)) | ||
|
||
return | ||
} | ||
|
||
for { | ||
select { | ||
case <-ctx.Done(): | ||
return | ||
case evt := <-eventChan: | ||
serverEvent, ok := evt.Event.(logparse.VoteKickDetailsEvt) | ||
if !ok { | ||
continue | ||
} | ||
|
||
matchID, _ := r.matchUsecase.GetMatchIDFromServerID(evt.ServerID) | ||
|
||
} | ||
} | ||
} | ||
|
||
func (r voteRepository) AddVoteHistory() error { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters