new slot
This commit is contained in:
parent
f1d156ea84
commit
b4bbd427aa
46
database.go
46
database.go
@ -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) {
|
func (r *Log4OMContactsRepository) ListByCountryBand(countryID string, band string, contactsBandChan chan []Contact, wg *sync.WaitGroup) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
rows, err := r.db.Query("SELECT callsign, band, mode, dxcc, stationcallsign, country FROM log WHERE dxcc = ? AND band = ?", countryID, band)
|
rows, err := r.db.Query("SELECT callsign, band, mode, dxcc, stationcallsign, country FROM log WHERE dxcc = ? AND band = ?", countryID, band)
|
||||||
|
@ -34,6 +34,7 @@ type FlexSpot struct {
|
|||||||
NewDXCC bool
|
NewDXCC bool
|
||||||
NewBand bool
|
NewBand bool
|
||||||
NewMode bool
|
NewMode bool
|
||||||
|
NewSlot bool
|
||||||
Worked bool
|
Worked bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,6 +165,7 @@ func (fc *FlexClient) SendSpottoFlex(spot TelnetSpot) {
|
|||||||
NewDXCC: spot.NewDXCC,
|
NewDXCC: spot.NewDXCC,
|
||||||
NewBand: spot.NewBand,
|
NewBand: spot.NewBand,
|
||||||
NewMode: spot.NewMode,
|
NewMode: spot.NewMode,
|
||||||
|
NewSlot: spot.NewSlot,
|
||||||
Worked: spot.CallsignWorked,
|
Worked: spot.CallsignWorked,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +201,10 @@ func (fc *FlexClient) SendSpottoFlex(spot TelnetSpot) {
|
|||||||
flexSpot.Priority = "3"
|
flexSpot.Priority = "3"
|
||||||
flexSpot.BackgroundColor = "#ff000000"
|
flexSpot.BackgroundColor = "#ff000000"
|
||||||
flexSpot.Comment = flexSpot.Comment + " [New Band]"
|
flexSpot.Comment = flexSpot.Comment + " [New Band]"
|
||||||
|
} else if !spot.NewBand && !spot.NewMode && !spot.NewDXCC && !spot.CallsignWorked && spot.NewSlot {
|
||||||
|
flexSpot.Color = "#ffeaeaa0"
|
||||||
|
flexSpot.Priority = "5"
|
||||||
|
flexSpot.BackgroundColor = "#ff000000"
|
||||||
} else if !spot.NewBand && !spot.NewMode && !spot.NewDXCC && !spot.CallsignWorked {
|
} else if !spot.NewBand && !spot.NewMode && !spot.NewDXCC && !spot.CallsignWorked {
|
||||||
flexSpot.Color = "#ffeaeaea"
|
flexSpot.Color = "#ffeaeaea"
|
||||||
flexSpot.Priority = "5"
|
flexSpot.Priority = "5"
|
||||||
|
16
spot.go
16
spot.go
@ -23,6 +23,7 @@ type TelnetSpot struct {
|
|||||||
NewDXCC bool
|
NewDXCC bool
|
||||||
NewBand bool
|
NewBand bool
|
||||||
NewMode bool
|
NewMode bool
|
||||||
|
NewSlot bool
|
||||||
CallsignWorked bool
|
CallsignWorked bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,12 +53,14 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChanToFlex chan Te
|
|||||||
spot.NewBand = false
|
spot.NewBand = false
|
||||||
spot.NewMode = false
|
spot.NewMode = false
|
||||||
spot.NewDXCC = false
|
spot.NewDXCC = false
|
||||||
|
spot.NewSlot = false
|
||||||
|
|
||||||
contactRepo := NewLog4OMContactsRepository(Cfg.SQLite.SQLitePath)
|
contactRepo := NewLog4OMContactsRepository(Cfg.SQLite.SQLitePath)
|
||||||
defer contactRepo.db.Close()
|
defer contactRepo.db.Close()
|
||||||
|
|
||||||
contactsChan := make(chan []Contact)
|
contactsChan := make(chan []Contact)
|
||||||
contactsModeChan := make(chan []Contact)
|
contactsModeChan := make(chan []Contact)
|
||||||
|
contactsModeBandChan := make(chan []Contact)
|
||||||
contactsBandChan := make(chan []Contact)
|
contactsBandChan := make(chan []Contact)
|
||||||
contactsCallChan := make(chan []Contact)
|
contactsCallChan := make(chan []Contact)
|
||||||
|
|
||||||
@ -76,6 +79,9 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChanToFlex chan Te
|
|||||||
go contactRepo.ListByCallSign(spot.DX, spot.Band, spot.Mode, contactsCallChan, wg)
|
go contactRepo.ListByCallSign(spot.DX, spot.Band, spot.Mode, contactsCallChan, wg)
|
||||||
contactsCall := <-contactsCallChan
|
contactsCall := <-contactsCallChan
|
||||||
|
|
||||||
|
go contactRepo.ListByCountryModeBand(spot.DX, spot.Band, spot.Mode, contactsModeBandChan, wg)
|
||||||
|
contactsModeBand := <-contactsCallChan
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
if len(contacts) == 0 {
|
if len(contacts) == 0 {
|
||||||
@ -88,6 +94,11 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChanToFlex chan Te
|
|||||||
if len(contactsBand) == 0 {
|
if len(contactsBand) == 0 {
|
||||||
spot.NewBand = true
|
spot.NewBand = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(contactsModeBand) == 0 {
|
||||||
|
spot.NewSlot = true
|
||||||
|
}
|
||||||
|
|
||||||
if len(contactsCall) > 0 {
|
if len(contactsCall) > 0 {
|
||||||
spot.CallsignWorked = true
|
spot.CallsignWorked = true
|
||||||
}
|
}
|
||||||
@ -115,6 +126,11 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChanToFlex chan Te
|
|||||||
spot.DX, spot.Spotter, spot.Frequency, spot.Band, spot.Mode, spot.Comment, spot.Time, spot.DXCC)
|
spot.DX, spot.Spotter, spot.Frequency, spot.Band, spot.Mode, spot.Comment, spot.Time, spot.DXCC)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !spot.NewDXCC && spot.NewSlot && spot.Mode != "" {
|
||||||
|
Log.Debugf("(** New Slot **) DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - DXCC: %s",
|
||||||
|
spot.DX, spot.Spotter, spot.Frequency, spot.Band, spot.Mode, spot.Comment, spot.Time, spot.DXCC)
|
||||||
|
}
|
||||||
|
|
||||||
if !spot.NewDXCC && !spot.NewBand && !spot.NewMode && spot.CallsignWorked {
|
if !spot.NewDXCC && !spot.NewBand && !spot.NewMode && spot.CallsignWorked {
|
||||||
Log.Debugf("(** Worked **) DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - DXCC: %s",
|
Log.Debugf("(** Worked **) DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - DXCC: %s",
|
||||||
spot.DX, spot.Spotter, spot.Frequency, spot.Band, spot.Mode, spot.Comment, spot.Time, spot.DXCC)
|
spot.DX, spot.Spotter, spot.Frequency, spot.Band, spot.Mode, spot.Comment, spot.Time, spot.DXCC)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user