<commit_before>import framework.util as util
import giveaminute.location as mLocation
from framework.controller import *

class Search(Controller):
    def GET(self, action=None):
        if action == 'map':
            return self.render('map', {'neighborhoodJSON':self.getLocationJSON()})
        else:
            log.info("*** render search")
            return self.render('search')   
            
    def getLocationJSON(self):
        data = mLocation.getLocationsWithScoring(self.db)
        
        locations = {}
        
        for item in data:
            locations[item.name] = {'location_id':item.location_id, 'lat':str(item.lat), 'lon':str(item.lon), 'score': (item.score if item.score else 0)}
            
        return self.json(dict(locations))            
            
            
<commit_msg>new map data format and location info<commit_after>import framework.util as util
import giveaminute.location as mLocation
from framework.controller import *

class Search(Controller):
    def GET(self, action=None):
        if action == 'map':
            return self.render('map', {'neighborhoodJSON':self.getLocationJSON()})
        else:
            log.info("*** render search")
            return self.render('search')
            
    def POST(self, action=None):
        if (action == 'info'):
            return self.getLocationInfoJSON()
        else:
            return self.not_found()
            
    def getLocationJSON(self):
        data = mLocation.getLocationsWithScoring(self.db)
        
        locations = []
        
        for item in data:
            locations.append(dict(name = item.name, 
                                location_id = item.location_id, 
                                lat = str(item.lat), 
                                lon = str(item.lon),
                                score = (item.score if item.score else 0)))
            
        return self.json(locations)
        
    def getLocationInfoJSON(self):
        locationId = self.request('location_id')
    
        info = mLocation.getLocationInfo(self.db, locationId)
        
        return self.json(info)
            
            

{'fraction_non_alphanumeric': 0.1031929662193429, 'fraction_numerical': 0.0009254974548819991, 'mean_word_length': 1.7332490518331227, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4597624', 'n_tokens_mistral': 567, 'n_tokens_neox': 552, 'n_words': 128}