Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions openprocurement/auction/plannings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import iso8601

from datetime import datetime
from time import mktime, time
from time import time
from gevent.subprocess import check_call

from openprocurement.auction.systemd_msgs_ids import (
Expand All @@ -19,7 +19,7 @@
PreAnnounce_view
)
from openprocurement.auction.utils import (
do_until_success, prepare_auction_worker_cmd
do_until_success, prepare_auction_worker_cmd, get_timestamp
)


Expand Down Expand Up @@ -49,8 +49,7 @@ def __iter__(self):
start_date = start_date.astimezone(self.bridge.tz)
auctions_start_in_date = startDate_view(
self.bridge.db,
key=(mktime(start_date.timetuple()) +
start_date.microsecond / 1E6) * 1000
key=get_timestamp(start_date)
)
if datetime.now(self.bridge.tz) > start_date:
LOGGER.info(
Expand Down Expand Up @@ -90,8 +89,7 @@ def __iter__(self):
start_date = start_date.astimezone(self.bridge.tz)
auctions_start_in_date = startDate_view(
self.bridge.db,
key=(mktime(start_date.timetuple()) +
start_date.microsecond / 1E6) * 1000
key=get_timestamp(start_date)
)
if datetime.now(self.bridge.tz) > start_date:
LOGGER.info(
Expand Down Expand Up @@ -196,8 +194,7 @@ def __iter__(self):
start_date = start_date.astimezone(self.bridge.tz)
auctions_start_in_date = startDate_view(
self.bridge.db,
key=(mktime(start_date.timetuple()) +
start_date.microsecond / 1E6) * 1000
key=get_timestamp(start_date)
)
if datetime.now(self.bridge.tz) > start_date:
LOGGER.info(
Expand Down
13 changes: 13 additions & 0 deletions openprocurement/auction/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from fractions import Fraction
from munch import Munch
from zope.interface import implementer
from time import mktime

from openprocurement.auction.interfaces import IFeedItem
from openprocurement.auction.constants import DEFAULT_CONFIG
Expand Down Expand Up @@ -482,3 +483,15 @@ def check_workers(plugins):

if exceptions:
raise exceptions[0]


def get_timestamp(date):
"""
Convert datetime.datetime object to timestamp

:param date: date object
:type date: datetime.datetime
:return: timestamp in milliseconds
:rtype: int
"""
return int((mktime(date.timetuple()) + date.microsecond / 1E6) * 1000)