Work in progress
This commit is contained in:
parent
c91a8a5c9c
commit
daa6941672
16
server.go
16
server.go
@ -52,14 +52,24 @@ func executeQuery(rw http.ResponseWriter, req *http.Request) {
|
||||
entries := getRecords(queryContext{geo, request.Profile, request.WalkingDist})
|
||||
features := fixFeatures(request.Features)
|
||||
|
||||
foundEntries := findRecords(entries, features, request.MinScore)
|
||||
minScore := request.MinScore
|
||||
if request.Bracket != nil {
|
||||
bracket := namedBracket{
|
||||
request.Bracket.Name,
|
||||
request.Bracket.Min,
|
||||
request.Bracket.Max}
|
||||
|
||||
minScore = calibrateMinScore(entries, features, bracket)
|
||||
}
|
||||
|
||||
foundEntries := findRecords(entries, features, minScore)
|
||||
sorter := recordSorter{entries: foundEntries, key: request.SortKey, ascending: request.SortAsc}
|
||||
sorter.sort()
|
||||
|
||||
response := jsonQueryResponse{
|
||||
Count: len(foundEntries),
|
||||
Columns: make(map[string]jsonColumn),
|
||||
MinScore: request.MinScore,
|
||||
MinScore: minScore,
|
||||
Records: make([]jsonRecord, 0)}
|
||||
|
||||
for name, value := range features {
|
||||
@ -72,7 +82,7 @@ func executeQuery(rw http.ResponseWriter, req *http.Request) {
|
||||
entries,
|
||||
features,
|
||||
name,
|
||||
request.MinScore,
|
||||
minScore,
|
||||
request.Resolution)
|
||||
|
||||
for _, hint := range hints {
|
||||
|
@ -27,7 +27,16 @@
|
||||
|
||||
function onStateChanged(name, value, bracket) {
|
||||
_ctx.query.features[name] = value;
|
||||
_ctx.query.bracket = bracket === null ? null : {name: name, bracket: bracket};
|
||||
if (bracket === null) {
|
||||
_ctx.query.bracket = null;
|
||||
}
|
||||
else {
|
||||
_ctx.query.bracket = {
|
||||
name: name,
|
||||
min: bracket.min,
|
||||
max: bracket.max
|
||||
};
|
||||
}
|
||||
|
||||
$.post('/query', JSON.stringify(_ctx.query), function(results) {
|
||||
saveSnapshot(results);
|
||||
|
4
types.go
4
types.go
@ -80,8 +80,8 @@ type jsonBracket struct {
|
||||
}
|
||||
|
||||
type jsonNamedBracket struct {
|
||||
Bracket jsonBracket `json:"bracket"`
|
||||
Name string `json:"name"`
|
||||
jsonBracket
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type jsonQueryResponse struct {
|
||||
|
4
util.go
4
util.go
@ -100,6 +100,10 @@ func findRecords(entries records, features featureMap, minScore float64) records
|
||||
return foundEntries
|
||||
}
|
||||
|
||||
func calibrateMinScore(entries records, features featureMap, bracket namedBracket) float64 {
|
||||
return 2
|
||||
}
|
||||
|
||||
func project(entries records, features featureMap, featureName string, minScore float64, steps int) []queryProjection {
|
||||
sampleFeatures := make(featureMap)
|
||||
for key, value := range features {
|
||||
|
Loading…
Reference in New Issue
Block a user