Ejemplo n.º 1
0
	def get(self):
		template = jinja_environment.get_template('detail.html')
		
		template_values = {}

		today = datetime.date.today()

		twitter_qry = Summary.query(Summary.date == today, Summary.size <= 140).order(-Summary.size, -Summary.count)
		longform_query = Summary.query(Summary.date == today, Summary.size > 140).order(-Summary.size, -Summary.count)
		template_values["twitter"] = twitter_qry.iter()
		template_values["longform"] = longform_query.iter()

		self.response.out.write(template.render(template_values))
Ejemplo n.º 2
0
	def get(self, target_date, restriction=None):
		template = jinja_environment.get_template('index.html')
		
		template_values = {}

		cache_key = "today." + target_date

		all_data = memcache.get(cache_key)

		target_day = datetime.datetime.strptime(target_date, '%Y-%m-%d').date()

		if not all_data:

			all_query = Summary.query(Summary.date == target_day, Summary.count > 1).order(-Summary.count)

			all_data = [SummaryInfo(count=x.count, text=x.text, checksum=x.checksum, length=len(x.text)) for x in all_query.iter()]

			try:
				memcache.set(cache_key, all_data, 5 * 60)
			except:
				pass

		template_values["all"] = all_data

		headers.set_cache_headers(self.response, 60)

		self.response.out.write(template.render(template_values))
Ejemplo n.º 3
0
    def get(self, target_date, restriction=None):
        template = jinja_environment.get_template('index.html')

        template_values = {}

        cache_key = "today." + target_date

        all_data = memcache.get(cache_key)

        target_day = datetime.datetime.strptime(target_date, '%Y-%m-%d').date()

        if not all_data:

            all_query = Summary.query(Summary.date == target_day,
                                      Summary.count > 1).order(-Summary.count)

            all_data = [
                SummaryInfo(count=x.count,
                            text=x.text,
                            checksum=x.checksum,
                            length=len(x.text)) for x in all_query.iter()
            ]

            try:
                memcache.set(cache_key, all_data, 5 * 60)
            except:
                pass

        template_values["all"] = all_data

        headers.set_cache_headers(self.response, 60)

        self.response.out.write(template.render(template_values))
Ejemplo n.º 4
0
def read_summary_data(target_date):
	all_query = Summary.query(Summary.date == target_date, Summary.count > 5).order(-Summary.count)

	def summary_as_map(summary):
		return {"count" : x.count,
			"text" : x.text,
			"detail_url" : "http://gu-text-catcher.appspot.com/content/{id}".format(id=x.checksum),
			}

	return [summary_as_map(x) for x in all_query.iter()]
Ejemplo n.º 5
0
    def get(self):

        cache_key = "today.all"

        all_data = memcache.get(cache_key)

        today = datetime.date.today()

        if not all_data:

            all_query = Summary.query(Summary.date == today,
                                      Summary.count > 1).order(-Summary.count)

            all_data = [
                SummaryInfo(count=x.count, text=x.text, checksum=x.checksum)
                for x in all_query.iter()
            ]

            memcache.set(cache_key, all_data, 45)

        self.response.out.write("OK")
Ejemplo n.º 6
0
	def get(self):
		template = jinja_environment.get_template('index.html')
		
		template_values = {}

		cache_key = "today.all"

		all_data = memcache.get(cache_key)

		today = datetime.date.today()

		if not all_data:

			all_query = Summary.query(Summary.date == today, Summary.count > 1).order(-Summary.count)

			all_data = [SummaryInfo(count=x.count, text=x.text, checksum=x.checksum, length=len(x.text)) for x in all_query.iter()]

		template_values["all"] = all_data

		headers.set_cache_headers(self.response, 60)

		self.response.out.write(template.render(template_values))