Skip to content

Commit

Permalink
Update documentation, remove a bunch of unneccessary timestamp coercion.
Browse files Browse the repository at this point in the history
  • Loading branch information
shakefu committed Aug 9, 2013
1 parent be72e84 commit ff23fb1
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions humbledb/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,12 @@ def _update_query(cls, stamp, count=1):
"""
Return the update query for the datetime `stamp`.
:param stamp: A datetime
:param stamp: A UTC datetime
:param count: Number to increment
:type stamp: datetime.datetime
:type count: int
"""
stamp = stamp or pytool.time.utcnow()

# Compose an update clause for all intervals
update = {}
for interval in cls.config_intervals:
Expand All @@ -186,7 +184,7 @@ def _update_clause(cls, interval, stamp, count=1):
clause.
:param interval: Time interval being recorded
:param stamp: Datetime being recorded
:param stamp: A UTC datetime being recorded
:param count: Number to increment
:type interval: int
:type stamp: datetime.datetime
Expand Down Expand Up @@ -236,8 +234,8 @@ def _attempt_preallocation(cls, event, stamp):
preallocated and do so.
:param event: Event identifier string
:param stamp: A UTC datetime indicating the document period
:type event: str
:param stamp: A datetime indicating the document period
:type stamp: datetime.datetime
"""
Expand All @@ -260,13 +258,11 @@ def _preallocate(cls, event, stamp):
`stamp`.
:param event: Event identifier string
:param stamp: A UTC datetime indicating the document period
:type event: str
:param stamp: A datetime indicating the document period
:type stamp: datetime.datetime
"""
# Convert the stamp to UTC or get the current UTC time
stamp = pytool.time.as_utc(stamp) if stamp else pytool.time.utcnow()
# Get the time period for this report
period = cls._period(stamp)
# If we already have preallocated for this time period, get out of here
Expand Down Expand Up @@ -305,14 +301,12 @@ def _preallocate_query(cls, event, stamp):
Return the query and update for preallocating a document.
:param event: Event identifier string
:param stamp: A UTC datetime indicating the document period
:type event: str
:param stamp: A datetime indicating the document period
:type stamp: datetime.datetime
"""
period = cls.config_period
# Ensure we're always working with UTC
stamp = pytool.time.as_utc(stamp)

# Build the base query, which is just a lookup against the id
query = {'_id': cls.record_id(event, stamp)}
Expand All @@ -325,9 +319,7 @@ def _preallocate_query(cls, event, stamp):
# for each interval key
query[key] = {'$exists': 0}
# Update the update clause with the preallocated structures
prealloc = {key: cls._preallocate_interval(period, interval,
stamp)}
update.update(prealloc)
update[key] = cls._preallocate_interval(period, interval, stamp)

update[cls.meta.event] = event
update[cls.meta.period] = cls._period(stamp)
Expand Down

0 comments on commit ff23fb1

Please sign in to comment.