This commit is contained in:
2024-10-22 00:32:59 +07:00
parent ecedb0ea5d
commit 83816777b7
7 changed files with 363 additions and 841 deletions

29
spot.go
View File

@ -4,10 +4,8 @@ import (
"regexp"
"strconv"
"strings"
"time"
_ "github.com/mattn/go-sqlite3"
log "github.com/sirupsen/logrus"
)
type TelnetSpot struct {
@ -27,7 +25,7 @@ type TelnetSpot struct {
CallsignWorked bool
}
func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSpot, log *log.Logger, Countries Countries) {
func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSpot, Countries Countries) {
match := re.FindStringSubmatch(spotRaw)
if len(match) != 0 {
@ -40,30 +38,21 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSp
Time: match[6],
}
start := time.Now()
spot.DXCC = GetDXCC(spot.DX, Countries)
elapsed := time.Since(start)
Log.Infof("Loop for DXCC: %s", elapsed)
spot.GetBand()
spot.GuessMode()
spot.CallsignWorked = false
spot.NewBand = false
spot.NewMode = false
spot.NewDXCC = false
contactRepo := NewLog4OMContactsRepository(Cfg.SQLite.SQLitePath, log)
contactRepo := NewLog4OMContactsRepository(Cfg.SQLite.SQLitePath)
defer contactRepo.db.Close()
start = time.Now()
contacts, _ := contactRepo.ListByCountry(spot.DXCC)
contactsMode, _ := contactRepo.ListByCountryMode(spot.DXCC, spot.Mode)
contactsBand, _ := contactRepo.ListByCountryBand(spot.DXCC, spot.Band)
contactsCall, _ := contactRepo.ListByCallSign(spot.DX, spot.Band, spot.Mode)
elapsed = time.Since(start)
Log.Infof("Elapsed db checking %s", elapsed)
if len(contacts) == 0 {
switch spot.DXCC {
@ -86,34 +75,36 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSp
SpotChan <- spot
if spot.NewDXCC {
log.Debugf("(** New DXCC **) DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - Command: %v, FlexSpot: %v",
Log.Debugf("(** New DXCC **) DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - Command: %v, FlexSpot: %v",
spot.DX, spot.Spotter, spot.Frequency, spot.Band, spot.Mode, spot.Comment, spot.Time, spot.CommandNumber, spot.FlexSpotNumber)
}
if !spot.NewDXCC && spot.NewBand && spot.NewMode {
log.Debugf("(** New Band/Mode **) DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - DXCC: %s",
Log.Debugf("(** New Band/Mode **) 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 {
log.Debugf("(** New Band **) DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - DXCC: %s",
Log.Debugf("(** New Band **) 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.Mode != "" {
log.Debugf("(** New Mode **) DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - DXCC: %s",
Log.Debugf("(** New Mode **) 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 {
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)
}
if !spot.NewDXCC && !spot.NewBand && !spot.NewMode {
log.Debugf("DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - DXCC: %s",
Log.Debugf("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)
}
} else {
Log.Infof("Could not decode: %s", strings.Trim(spotRaw, "\n"))
}
}