-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
58 changed files
with
1,212 additions
and
17 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM golang:1.22-alpine as golang | ||
|
||
RUN apk --no-cache add tzdata | ||
|
||
RUN apk --update add ca-certificates | ||
|
||
LABEL author="Indra Pramana" | ||
|
||
RUN mkdir -p /logs/http | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
RUN go mod download | ||
RUN go mod verify | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /fb-alert . | ||
|
||
FROM scratch | ||
|
||
COPY --from=golang /usr/share/zoneinfo /usr/share/zoneinfo | ||
COPY --from=golang /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=golang /etc/passwd /etc/passwd | ||
COPY --from=golang /etc/group /etc/group | ||
COPY --from=golang /bin/sh /bin/sh | ||
|
||
COPY --from=golang /fb-alert . | ||
|
||
CMD ["/fb-alert", "scraper"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package entity | ||
|
||
type Away struct { | ||
ID int64 `json:"id,omitempty"` | ||
FixtureID int64 `json:"fixture_id"` | ||
Fixture *Fixture `json:"fixture"` | ||
TeamID int64 `json:"team_id"` | ||
Team *Team `json:"team"` | ||
Goal int `json:"goal"` | ||
IsWinner bool `gorm:"type:bool;default:false" json:"is_winner"` | ||
} |
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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
package entity | ||
|
||
type COntent struct { | ||
type Content struct { | ||
ID int `gorm:"primaryKey" json:"id"` | ||
ServiceID int `json:"service_id"` | ||
Service *Service `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"service,omitempty"` | ||
Key string `gorm:"size:50" json:"key"` | ||
Value string `gorm:"size:150" json:"value"` | ||
} |
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 |
---|---|---|
@@ -1,4 +1,13 @@ | ||
package entity | ||
|
||
type Fixture struct { | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
Referee string `json:"referee"` | ||
Timezone string `json:"timezone"` | ||
Date string `json:"date"` | ||
TimeStamp int `json:"timestamp"` | ||
HomeID int64 `json:"home_id"` | ||
Home *Home `json:"home"` | ||
AwayID int64 `json:"away_id"` | ||
Away *Away `json:"away"` | ||
} |
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,11 @@ | ||
package entity | ||
|
||
type Home struct { | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
FixtureID int64 `json:"fixture_id"` | ||
Fixture *Fixture `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"fixture,omitempty"` | ||
TeamID int64 `json:"team_id"` | ||
Team *Team `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"team,omitempty"` | ||
Goal int `gorm:"size:10" json:"goal"` | ||
IsWinner bool `gorm:"type:bool;default:false" json:"is_winner"` | ||
} |
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 |
---|---|---|
@@ -1 +1,6 @@ | ||
package entity | ||
|
||
type League struct { | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
Name string `json:"name"` | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
package entity | ||
|
||
type Livescore struct { | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
} |
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
package entity | ||
|
||
type News struct { | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
FixtureID int64 `json:"fixture_id"` | ||
Fixture *Fixture `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"fixture,omitempty"` | ||
} |
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,35 @@ | ||
package entity | ||
|
||
type Pagination struct { | ||
Limit int `json:"limit,omitempty" query:"limit"` | ||
Page int `json:"page,omitempty" query:"page"` | ||
Sort string `json:"sort,omitempty" query:"sort"` | ||
TotalRows int64 `json:"total_rows"` | ||
TotalPages int `json:"total_pages"` | ||
Rows interface{} `json:"rows"` | ||
} | ||
|
||
func (p *Pagination) GetOffset() int { | ||
return (p.GetPage() - 1) * p.GetLimit() | ||
} | ||
|
||
func (p *Pagination) GetLimit() int { | ||
if p.Limit == 0 { | ||
p.Limit = 10 | ||
} | ||
return p.Limit | ||
} | ||
|
||
func (p *Pagination) GetPage() int { | ||
if p.Page == 0 { | ||
p.Page = 1 | ||
} | ||
return p.Page | ||
} | ||
|
||
func (p *Pagination) GetSort() string { | ||
if p.Sort == "" { | ||
p.Sort = "Id desc" | ||
} | ||
return p.Sort | ||
} |
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
package entity | ||
|
||
type Prediction struct { | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
FixtureID int64 `json:"fixture_id"` | ||
Fixture *Fixture `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"fixture,omitempty"` | ||
} |
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,11 @@ | ||
package entity | ||
|
||
type Reward struct { | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
FixtureID int64 `json:"fixture_id"` | ||
Fixture *Fixture `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"fixture,omitempty"` | ||
SubscriptionID int64 `json:"subscription_id"` | ||
Subscription *Subscription `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"subscription,omitempty"` | ||
Msisdn string `gorm:"size:15;not null" json:"msisdn"` | ||
Amount float64 `gorm:"size:8;default:0" json:"amount"` | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
package entity | ||
|
||
type Schedule struct { | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
package entity | ||
|
||
type Season struct { | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
} |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
package entity | ||
|
||
type Service struct { | ||
ID int `gorm:"primaryKey" json:"id"` | ||
Name string `json:"name"` | ||
} |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
package entity | ||
|
||
type Subscription struct { | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
ServiceID int `json:"service_id"` | ||
Service *Service `json:"service"` | ||
Msisdn string `gorm:"size:15;not null" json:"msisdn"` | ||
} |
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 |
---|---|---|
@@ -1 +1,24 @@ | ||
package entity | ||
|
||
type Team struct { | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
Name string `json:"name"` | ||
Slug string `json:"slug"` | ||
Logo string `json:"logo"` | ||
} | ||
|
||
func (e *Team) GetId() int64 { | ||
return e.ID | ||
} | ||
|
||
func (e *Team) GetName() string { | ||
return e.Name | ||
} | ||
|
||
func (e *Team) GetSlug() string { | ||
return e.Slug | ||
} | ||
|
||
func (e *Team) GetLogo() string { | ||
return e.Logo | ||
} |
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,10 @@ | ||
package entity | ||
|
||
type Transaction struct { | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
SubscriptionID int64 `json:"subscription_id"` | ||
Subscription *Subscription `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"subscription,omitempty"` | ||
ServiceID int `json:"service_id"` | ||
Service *Service `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"service,omitempty"` | ||
Msisdn string `gorm:"size:15;not null" json:"msisdn"` | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package entity | ||
|
||
type Ussd struct { | ||
ID int64 `json:"id"` | ||
ID int64 `gorm:"primaryKey" json:"id"` | ||
Msisdn string `json:"msisdn"` | ||
} |
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
internal/domain/model/football.go → internal/domain/model/response.go
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package repository | ||
|
||
import ( | ||
"github.com/idprm/go-football-alert/internal/domain/entity" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type AwayRepository struct { | ||
db *gorm.DB | ||
} | ||
|
||
func NewAwayRepository(db *gorm.DB) *AwayRepository { | ||
return &AwayRepository{ | ||
db: db, | ||
} | ||
} | ||
|
||
type IAwayRepository interface { | ||
CountByTeamId(int) (int64, error) | ||
GetAllPaginate(*entity.Pagination) (*entity.Pagination, error) | ||
GetByTeamId(string) (*entity.Away, error) | ||
Save(*entity.Away) (*entity.Away, error) | ||
Update(*entity.Away) (*entity.Away, error) | ||
Delete(*entity.Away) error | ||
} | ||
|
||
func (r *AwayRepository) CountByTeamId(teamId int) (int64, error) { | ||
var count int64 | ||
err := r.db.Model(&entity.Away{}).Where("team_id = ?", teamId).Count(&count).Error | ||
if err != nil { | ||
return count, err | ||
} | ||
return count, nil | ||
} | ||
|
||
func (r *AwayRepository) GetAllPaginate(pagination *entity.Pagination) (*entity.Pagination, error) { | ||
var aways []*entity.Away | ||
err := r.db.Scopes(Paginate(aways, pagination, r.db)).Preload("Team").Find(&aways).Error | ||
if err != nil { | ||
return nil, err | ||
} | ||
pagination.Rows = aways | ||
return pagination, nil | ||
} | ||
|
||
func (r *AwayRepository) GetByTeamId(teamId int) (*entity.Away, error) { | ||
var away entity.Away | ||
err := r.db.Where("team_id = ?", teamId).Preload("Team").Take(&away).Error | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &away, nil | ||
} | ||
|
||
func (r *AwayRepository) Save(away *entity.Away) (*entity.Away, error) { | ||
err := r.db.Create(&away).Error | ||
if err != nil { | ||
return nil, err | ||
} | ||
return away, nil | ||
} | ||
|
||
func (r *AwayRepository) Update(away *entity.Away) (*entity.Away, error) { | ||
err := r.db.Where("id = ?", away.ID).Updates(&away).Error | ||
if err != nil { | ||
return nil, err | ||
} | ||
return away, nil | ||
} | ||
|
||
func (r *AwayRepository) Delete(p *entity.Away) error { | ||
err := r.db.Delete(&p, p.ID).Error | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
Oops, something went wrong.