<commit_before>"""Model classes for SacTraffic.

"""

import time

from datetime import datetime, timedelta

from google.appengine.ext import db
from google.appengine.api import memcache

from utils import tzinfo

class CHPData(db.Model):
	"""Holds the last successful CHP data fetch.

	"""
	data = db.BlobProperty(required=True)
	updated = db.DateTimeProperty(auto_now=True)

	def put(self):
		"""Stick the updated date into memcache on put().

		"""
		memcache.set("%s-updated" % self.key().id_or_name(), self.updated)
		db.Model.put(self)

	@classmethod
	def last_updated(cls):
		"""Gets the last updated date of the CHP Data.

		"""
		chp_data_last_updated = memcache.get("chp_data-updated")
		if chp_data_last_updated is None:
			chp_data = cls.get_by_key_name("chp_data")
			memcache.add("chp_data-updated", chp_data.updated)
			chp_data_last_updated = chp_data.updated

		return chp_data_last_updated


class CHPIncident(db.Model):
	"""Represents a CHP Incident.

	"""
	CenterID = db.StringProperty(required=True)
	DispatchID = db.StringProperty(required=True)
	LogID = db.StringProperty(required=True)
	LogTime = db.DateTimeProperty()
	LogType = db.StringProperty()
	LogTypeID = db.StringProperty()
	Location = db.StringProperty()
	Area = db.StringProperty()
	ThomasBrothers = db.TextProperty()
	TBXY = db.TextProperty()
	LogDetails = db.BlobProperty()
	geolocation = db.GeoPtProperty()
	city = db.StringProperty()
	updated = db.DateTimeProperty(auto_now=True)<commit_msg>Make sure we actually retrieve something from the datastore.<commit_after>"""Model classes for SacTraffic.

"""

import time

from datetime import datetime, timedelta

from google.appengine.ext import db
from google.appengine.api import memcache

from utils import tzinfo

class CHPData(db.Model):
	"""Holds the last successful CHP data fetch.

	"""
	data = db.BlobProperty(required=True)
	updated = db.DateTimeProperty(auto_now=True)

	def put(self):
		"""Stick the updated date into memcache on put().

		"""
		memcache.set("%s-updated" % self.key().id_or_name(), self.updated)
		db.Model.put(self)

	@classmethod
	def last_updated(cls):
		"""Gets the last updated date of the CHP Data.

		"""
		chp_data_last_updated = memcache.get("chp_data-updated")
		if chp_data_last_updated is None:
			chp_data = cls.get_by_key_name("chp_data")
			if chp_data is not None:
				memcache.add("chp_data-updated", chp_data.updated)
				chp_data_last_updated = chp_data.updated

		return chp_data_last_updated


class CHPIncident(db.Model):
	"""Represents a CHP Incident.

	"""
	CenterID = db.StringProperty(required=True)
	DispatchID = db.StringProperty(required=True)
	LogID = db.StringProperty(required=True)
	LogTime = db.DateTimeProperty()
	LogType = db.StringProperty()
	LogTypeID = db.StringProperty()
	Location = db.StringProperty()
	Area = db.StringProperty()
	ThomasBrothers = db.TextProperty()
	TBXY = db.TextProperty()
	LogDetails = db.BlobProperty()
	geolocation = db.GeoPtProperty()
	city = db.StringProperty()
	updated = db.DateTimeProperty(auto_now=True)
{'fraction_non_alphanumeric': 0.11524530786960817, 'fraction_numerical': 0.0, 'mean_word_length': 5.076, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '765076', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1026, 'n_words': 232}