Exemple #1
0
    def get(self):
        status['busy'] += 1
        images = cache.get_value('geotagged_images')
        if not images:
            query = '''SELECT image.id, ihash, lat, lng, altitude, extract(epoch from moment) as moment, filename, size, make, model, orientation, path, width, height, image.description 
            FROM image LEFT OUTER JOIN camera on image.camera_id = camera.id
            WHERE lat != %s and lng != %s'''
            data = (0, 0)
            images = yield database.raw_query(query, data)
            cache.set_value('geotagged_images', images)

        self.render('map.html', images=images)
        status['busy'] -= 1
Exemple #2
0
    def get(self, op):
        if op == 'get_stats':
            status['busy'] += 1
            stats = cache.get_value('stats')
            if not stats:
                query = '''SELECT image.id, extract(epoch from moment) as moment, lat, lng, size, make, model, width, height 
                FROM image LEFT OUTER JOIN camera on image.camera_id = camera.id'''
                
                stats = yield database.raw_query(query, ())
                cache.set_value('stats', stats)

            self.finish(json.dumps(stats))
            status['busy'] -= 1

        else:
            self.render('stats.html')
        max_pages=1,
        rows=5)

    papers = [
        dict(
            title="Execute query on the ADS website",
            subtitle=query_string,
            arg="https://ui.adsabs.harvard.edu/search/q=" + query_string,
        )
    ]
    for paper in request:
        papers.append(
            dict(
                title="{0} ({1})".format(paper.title[0], paper.year),
                subtitle=", ".join(paper.author),
                arg=URL_FORMAT(paper.bibcode),
            ))

    # Save the rate limit
    ratelimit = request.response.get_ratelimits()
    set_ratelimit(ratelimit)

    results = json.dumps(dict(items=papers))
    sys.stdout.write(results)

    # Save the results to the cache
    cache.set_value(query_string, results)

    # Clean up old entries in the cache
    cache.clean()