This commit is contained in:
2025-06-07 10:36:20 +02:00
parent f1d156ea84
commit b4bbd427aa
3 changed files with 68 additions and 0 deletions

View File

@ -161,6 +161,52 @@ func (r *Log4OMContactsRepository) ListByCountryMode(countryID string, mode stri
}
}
func (r *Log4OMContactsRepository) ListByCountryModeBand(countryID string, band string, mode string, contactsModeBandChan chan []Contact, wg *sync.WaitGroup) {
defer wg.Done()
if mode == "USB" || mode == "LSB" {
rows, err := r.db.Query("SELECT callsign, band, mode, dxcc, stationcallsign, country FROM log WHERE dxcc = ? AND (mode = ? OR mode = ?) AND band = ?", countryID, "USB", "LSB", band)
if err != nil {
log.Error("could not query database", err)
}
defer rows.Close()
contacts := []Contact{}
for rows.Next() {
c := Contact{}
if err := rows.Scan(&c.Callsign, &c.Band, &c.Mode, &c.DXCC, &c.StationCallsign, &c.Country); err != nil {
log.Error("could not query database", err)
}
contacts = append(contacts, c)
}
contactsModeBandChan <- contacts
} else {
rows, err := r.db.Query("SELECT callsign, band, mode, dxcc, stationcallsign, country FROM log WHERE dxcc = ? AND mode = ? AND band = ?", countryID, mode, band)
if err != nil {
log.Error("could not query the database", err)
}
defer rows.Close()
contacts := []Contact{}
for rows.Next() {
c := Contact{}
if err := rows.Scan(&c.Callsign, &c.Band, &c.Mode, &c.DXCC, &c.StationCallsign, &c.Country); err != nil {
fmt.Println(err)
}
contacts = append(contacts, c)
}
contactsModeBandChan <- contacts
}
}
func (r *Log4OMContactsRepository) ListByCountryBand(countryID string, band string, contactsBandChan chan []Contact, wg *sync.WaitGroup) {
defer wg.Done()
rows, err := r.db.Query("SELECT callsign, band, mode, dxcc, stationcallsign, country FROM log WHERE dxcc = ? AND band = ?", countryID, band)