linitng
This commit is contained in:
parent
031c3bfe4e
commit
64870c54bc
2 changed files with 3 additions and 48 deletions
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
|
@ -146,7 +145,7 @@ func (s *Server) Search(ctx context.Context, in *pb.SearchRequest) (*pb.Outputs,
|
||||||
var from = 0
|
var from = 0
|
||||||
var pageSize = 10
|
var pageSize = 10
|
||||||
var orderBy []orderField
|
var orderBy []orderField
|
||||||
var searchIndices = []string{}
|
var searchIndices []string
|
||||||
client := s.EsClient
|
client := s.EsClient
|
||||||
searchIndices = make([]string, 0, 1)
|
searchIndices = make([]string, 0, 1)
|
||||||
searchIndices = append(searchIndices, s.Args.EsIndex)
|
searchIndices = append(searchIndices, s.Args.EsIndex)
|
||||||
|
@ -269,9 +268,6 @@ func (s *Server) postProcessResults(
|
||||||
txos = append(txos, res)
|
txos = append(txos, res)
|
||||||
j += 1
|
j += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
//printJsonFullRecords(blockedRecords)
|
|
||||||
|
|
||||||
//Get claims for reposts
|
//Get claims for reposts
|
||||||
repostClaims, repostRecords, repostedMap := getClaimsForReposts(ctx, client, records, searchIndices)
|
repostClaims, repostRecords, repostedMap := getClaimsForReposts(ctx, client, records, searchIndices)
|
||||||
//get all unique channels
|
//get all unique channels
|
||||||
|
@ -317,7 +313,7 @@ func (s *Server) checkQuery(in *pb.SearchRequest) error {
|
||||||
for name, failed := range checks {
|
for name, failed := range checks {
|
||||||
if failed {
|
if failed {
|
||||||
time.Sleep(2) // throttle
|
time.Sleep(2) // throttle
|
||||||
return errors.New(fmt.Sprintf("%s cant have more than %d items.", name, limit))
|
return fmt.Errorf("%s cant have more than %d items", name, limit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -672,15 +668,6 @@ func searchAhead(searchHits []*record, pageSize int, perChannelPerPage int) []*r
|
||||||
return finalHits
|
return finalHits
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *record) recordToChannelOutput() *pb.Output {
|
|
||||||
// Don't nee dthe meta for this one
|
|
||||||
return &pb.Output{
|
|
||||||
TxHash: util.TxIdToTxHash(r.Txid),
|
|
||||||
Nout: r.Nout,
|
|
||||||
Height: r.Height,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *record) recordToOutput() *pb.Output {
|
func (r *record) recordToOutput() *pb.Output {
|
||||||
return &pb.Output{
|
return &pb.Output{
|
||||||
TxHash: util.TxIdToTxHash(r.Txid),
|
TxHash: util.TxIdToTxHash(r.Txid),
|
||||||
|
@ -776,35 +763,3 @@ func removeBlocked(searchHits []*record) ([]*record, []*record, map[string]*pb.B
|
||||||
|
|
||||||
return newHits, blockedHits, blockedChannels
|
return newHits, blockedHits, blockedChannels
|
||||||
}
|
}
|
||||||
|
|
||||||
func printJsonFullRecords(records []*record) {
|
|
||||||
// or if you want more control
|
|
||||||
for _, r := range records {
|
|
||||||
// hit.Index contains the name of the index
|
|
||||||
|
|
||||||
b, err := json.MarshalIndent(r, "", " ")
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("error:", err)
|
|
||||||
}
|
|
||||||
fmt.Println(string(b))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func printJsonFullResults(searchResult *elastic.SearchResult) {
|
|
||||||
// or if you want more control
|
|
||||||
for _, hit := range searchResult.Hits.Hits {
|
|
||||||
// hit.Index contains the name of the index
|
|
||||||
|
|
||||||
var t map[string]interface{} // or could be a Record
|
|
||||||
err := json.Unmarshal(hit.Source, &t)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
b, err := json.MarshalIndent(t, "", " ")
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("error:", err)
|
|
||||||
}
|
|
||||||
fmt.Println(string(b))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ type Args struct {
|
||||||
func MakeHubServer(args *Args) *Server {
|
func MakeHubServer(args *Args) *Server {
|
||||||
grpcServer := grpc.NewServer()
|
grpcServer := grpc.NewServer()
|
||||||
|
|
||||||
multiSpaceRe, err := regexp.Compile("\\s{2,}")
|
multiSpaceRe, err := regexp.Compile(`\s{2,}`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue