Skip to content

Commit 6e95416

Browse files
AlteredCoderjdv
authored andcommitted
Fix reports with too many IPs
1 parent ba80f87 commit 6e95416

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

pkg/database/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type Client struct {
1313

1414
func NewClient(sqliteDBPath string) (*Client, error) {
1515
client := &Client{}
16-
db, err := gorm.Open(sqlite.Open(sqliteDBPath), &gorm.Config{Logger: logger.Default.LogMode(logger.Silent)})
16+
db, err := gorm.Open(sqlite.Open(sqliteDBPath), &gorm.Config{Logger: logger.Default.LogMode(logger.Info)})
1717
if err != nil {
1818
return client, err
1919
}

pkg/database/report.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func (r *ReportClient) FindById(reportID uint) (*Report, error) {
7474
return nil, result.Error
7575
}
7676

77+
// Load IPs using Association API
7778
err := r.db.Model(&report).Association("IPs").Find(&report.IPs)
7879
if err != nil {
7980
return nil, err
@@ -98,6 +99,7 @@ func (r *ReportClient) FindByHash(filepath string) (*Report, error) {
9899
return nil, result.Error
99100
}
100101

102+
// Load IPs using Association API
101103
err = r.db.Model(&report).Association("IPs").Find(&report.IPs)
102104
if err != nil {
103105
return nil, err
@@ -191,6 +193,7 @@ func (r *ReportClient) FilePathExist(filePath string) (*Report, bool, error) {
191193
return nil, false, nil
192194
}
193195

196+
// Load IPs using Association API
194197
err := r.db.Model(&reports[0]).Association("IPs").Find(&reports[0].IPs)
195198
if err != nil {
196199
return nil, false, err

0 commit comments

Comments
 (0)