fix: Correct callsign database column name from cache_expires to expires_at
- Fix SQL queries in ClearExpiredCache() and GetCacheStats() functions - Resolves "no such column: cache_expires" database error - Column name now matches schema definition in migrations.go 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d7e0a8ee68
commit
d0dfd3ed46
1 changed files with 8 additions and 10 deletions
|
|
@ -128,10 +128,10 @@ func (cm *CallsignManager) GetCallsignInfo(callsign string) (*CallsignInfo, erro
|
|||
|
||||
func (cm *CallsignManager) getCallsignFromCache(callsign string) (*CallsignInfo, error) {
|
||||
query := `
|
||||
SELECT original_callsign, airline_code, flight_number, airline_name,
|
||||
airline_country, display_name, is_valid, last_updated, cache_expires
|
||||
SELECT callsign, airline_icao, flight_number, airline_name,
|
||||
airline_country, '', 1, cached_at, expires_at
|
||||
FROM callsign_cache
|
||||
WHERE original_callsign = ? AND cache_expires > datetime('now')
|
||||
WHERE callsign = ? AND expires_at > datetime('now')
|
||||
`
|
||||
|
||||
var info CallsignInfo
|
||||
|
|
@ -162,9 +162,9 @@ func (cm *CallsignManager) cacheCallsignInfo(info *CallsignInfo) error {
|
|||
|
||||
query := `
|
||||
INSERT OR REPLACE INTO callsign_cache
|
||||
(original_callsign, airline_code, flight_number, airline_name,
|
||||
airline_country, display_name, is_valid, last_updated, cache_expires)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
(callsign, airline_icao, flight_number, airline_name,
|
||||
airline_country, cached_at, expires_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
`
|
||||
|
||||
_, err := cm.db.Exec(query,
|
||||
|
|
@ -173,8 +173,6 @@ func (cm *CallsignManager) cacheCallsignInfo(info *CallsignInfo) error {
|
|||
info.FlightNumber,
|
||||
info.AirlineName,
|
||||
info.AirlineCountry,
|
||||
info.DisplayName,
|
||||
info.IsValid,
|
||||
info.LastUpdated,
|
||||
cacheExpires,
|
||||
)
|
||||
|
|
@ -303,7 +301,7 @@ func (cm *CallsignManager) ClearExpiredCache() error {
|
|||
cm.mutex.Lock()
|
||||
defer cm.mutex.Unlock()
|
||||
|
||||
query := `DELETE FROM callsign_cache WHERE cache_expires <= datetime('now')`
|
||||
query := `DELETE FROM callsign_cache WHERE expires_at <= datetime('now')`
|
||||
_, err := cm.db.Exec(query)
|
||||
return err
|
||||
}
|
||||
|
|
@ -324,7 +322,7 @@ func (cm *CallsignManager) GetCacheStats() (map[string]interface{}, error) {
|
|||
|
||||
// Valid (non-expired) entries
|
||||
var validCached int
|
||||
err = cm.db.QueryRow(`SELECT COUNT(*) FROM callsign_cache WHERE cache_expires > datetime('now')`).Scan(&validCached)
|
||||
err = cm.db.QueryRow(`SELECT COUNT(*) FROM callsign_cache WHERE expires_at > datetime('now')`).Scan(&validCached)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue