Beispiel #1
0
 def getRelatedProjects(self):
     ideaId = self.request('idea_id')
     limit = int(self.request('n_limit')) if self.request('n_limit') else 5
     relatedProjects = []
     citywideProjects = []
     kw = []
     isLocationOnlyMatch = False
     
     if (not ideaId):
         log.error("No idea id")
     else: 
         idea = mIdea.Idea(self.db, ideaId)
     
         if (idea):
             kw = mKeywords.getKeywords(self.db, idea.description)
             
             if (idea.locationId != -1):
                 relatedProjects = mProject.searchProjects(self.db, kw, idea.locationId, limit)
                 
                 if (len(relatedProjects) == 0):
                     isLocationOnlyMatch = True
                     relatedProjects = mProject.searchProjects(self.db, [], idea.locationId, limit)
                 
             citywideProjects = mProject.searchProjects(self.db, kw, -1, limit)
         else:
             log.error("No idea found for id = %s" % ideaId)
         
     obj = dict(is_location_only_match = isLocationOnlyMatch, related = relatedProjects, citywide = citywideProjects, search_terms = ','.join(kw))
         
     return self.json(obj)
Beispiel #2
0
    def getKeywordsJSON(self):
        s = "%s %s" % (self.request('text'), self.request('title'))
        kw = keywords.getKeywords(self.db, s)

        log.info(kw)

        obj = dict(suggested_keywords=kw)

        return self.json(obj)
Beispiel #3
0
    def getRelatedProjects(self):
        ideaId = self.request('idea_id')
        limit = int(self.request('n_limit')) if self.request('n_limit') else 5
        relatedProjects = []
        citywideProjects = []
        kw = []
        isLocationOnlyMatch = False

        if (not ideaId):
            log.error("No idea id")
        else:
            idea = mIdea.Idea(self.db, ideaId)

            if (idea):
                kw = mKeywords.getKeywords(self.db, idea.description)

                if (idea.locationId != -1):
                    relatedProjects = mProject.searchProjects(
                        self.db, kw, idea.locationId, limit)

                    if (len(relatedProjects) == 0):
                        isLocationOnlyMatch = True
                        relatedProjects = mProject.searchProjects(
                            self.db, [], idea.locationId, limit)

                citywideProjects = mProject.searchProjects(
                    self.db, kw, -1, limit)
            else:
                log.error("No idea found for id = %s" % ideaId)

        obj = dict(is_location_only_match=isLocationOnlyMatch,
                   related=relatedProjects,
                   citywide=citywideProjects,
                   search_terms=','.join(kw))

        return self.json(obj)