fix: local ticker search for screener (Sectors companies/ 401s on sub)

- q= now searches universe table locally (ticker + company_name LIKE, order by close) instead of calling the Sectors companies/ endpoint, which returns SUBSCRIPTION_DOES_NOT_ALLOW on the current subscription and silently fell back to the full 780-ticker universe
- removes the broken name-fill cmd + scheduler/one-shot Screen() name enrichment (wasted credits, empty names)
- Screener UI: search card says 'kode saham', results still show company name when present
This commit is contained in:
asepharyana
2026-09-16 14:30:22 +07:00
parent d7eb0a3abf
commit 49dd2101e0
5 changed files with 49 additions and 32 deletions
+13 -1
View File
@@ -46,7 +46,19 @@ func (s *Server) Screen(w http.ResponseWriter, r *http.Request) {
// Base universe: live screener when keyed, else stored watchlist.
var universe []string
names := map[string]string{}
if s.Cfg.HasSectorsKey() && (req.Where != "" || req.Q != "") {
// Free-text q → local universe search (ticker + company_name, offline).
// The Sectors companies/ endpoint is not on this subscription, so remote
// screening is skipped entirely to avoid a silent full-universe fallback.
if req.Q != "" {
if hits, err := s.DB.SearchTickers(req.Q, limit*2); err == nil {
for _, h := range hits {
universe = append(universe, h.Symbol)
if h.CompanyName != "" {
names[h.Symbol] = h.CompanyName
}
}
}
} else if s.Cfg.HasSectorsKey() && req.Where != "" {
if rows, err := s.Sectors.Screen(r.Context(), req.Where, req.Q, limit*2, 0); err == nil {
for _, row := range rows {
tk := strings.ToUpper(strings.TrimSuffix(row.Symbol, ".JK"))