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})
|
entries := getRecords(queryContext{geo, request.Profile, request.WalkingDist})
|
||||||
features := fixFeatures(request.Features)
|
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 := recordSorter{entries: foundEntries, key: request.SortKey, ascending: request.SortAsc}
|
||||||
sorter.sort()
|
sorter.sort()
|
||||||
|
|
||||||
response := jsonQueryResponse{
|
response := jsonQueryResponse{
|
||||||
Count: len(foundEntries),
|
Count: len(foundEntries),
|
||||||
Columns: make(map[string]jsonColumn),
|
Columns: make(map[string]jsonColumn),
|
||||||
MinScore: request.MinScore,
|
MinScore: minScore,
|
||||||
Records: make([]jsonRecord, 0)}
|
Records: make([]jsonRecord, 0)}
|
||||||
|
|
||||||
for name, value := range features {
|
for name, value := range features {
|
||||||
@ -72,7 +82,7 @@ func executeQuery(rw http.ResponseWriter, req *http.Request) {
|
|||||||
entries,
|
entries,
|
||||||
features,
|
features,
|
||||||
name,
|
name,
|
||||||
request.MinScore,
|
minScore,
|
||||||
request.Resolution)
|
request.Resolution)
|
||||||
|
|
||||||
for _, hint := range hints {
|
for _, hint := range hints {
|
||||||
|
@ -27,7 +27,16 @@
|
|||||||
|
|
||||||
function onStateChanged(name, value, bracket) {
|
function onStateChanged(name, value, bracket) {
|
||||||
_ctx.query.features[name] = value;
|
_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) {
|
$.post('/query', JSON.stringify(_ctx.query), function(results) {
|
||||||
saveSnapshot(results);
|
saveSnapshot(results);
|
||||||
|
2
types.go
2
types.go
@ -80,7 +80,7 @@ type jsonBracket struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type jsonNamedBracket struct {
|
type jsonNamedBracket struct {
|
||||||
Bracket jsonBracket `json:"bracket"`
|
jsonBracket
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
util.go
4
util.go
@ -100,6 +100,10 @@ func findRecords(entries records, features featureMap, minScore float64) records
|
|||||||
return foundEntries
|
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 {
|
func project(entries records, features featureMap, featureName string, minScore float64, steps int) []queryProjection {
|
||||||
sampleFeatures := make(featureMap)
|
sampleFeatures := make(featureMap)
|
||||||
for key, value := range features {
|
for key, value := range features {
|
||||||
|
Loading…
Reference in New Issue
Block a user