in scheduler/scheduler.py [0:0]
def get_messages(self, compare_date='', ready_only=True, **kwargs):
include_expired = kwargs.get('IncludeExpired', False)
self.log.debug("Checking for scheduled messages: compare_date={}," +
"ready_only={}".format(compare_date, bool(ready_only)))
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table(MESSAGE_SCHEDULE_DB)
response = table.scan(
Select='ALL_ATTRIBUTES'
)
scheduled_messages = []
if not compare_date:
compare_date = arrow.utcnow()
self.log.debug('Checking messages using uctnow since compare_dt ' +
'is empty, compare_date=%s'
% compare_date.isoformat())
self.log.debug("Total number of scheduled messages in table %s: %s"
% (MESSAGE_SCHEDULE_DB, len(response['Items'])))
for item in response['Items']:
m = convert_to_scheduled_message(item)
if m.no_more_occurrences and not include_expired:
continue
self.log.debug('Message: {}'.format(m.body))
if not ready_only or (ready_only and
m.is_message_ready(
CompareDateTimeInUtc=compare_date)):
self.log.debug('Adding message to response:')
scheduled_messages.append(convert_to_scheduled_message(item))
else:
self.log.debug('Skipping message, ready_only=%s, msg_rdy=%s'
% (ready_only, m.is_message_ready(
CompareDateTimeInUtc=compare_date)))
self.log.debug("Number of scheduled messages: %s"
% len(scheduled_messages))
return scheduled_messages