Subversion Repositories SmartDukaan

Rev

Rev 19337 | Rev 19350 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19337 Rev 19340
Line 1... Line 1...
1
from bson.objectid import ObjectId
1
from bson.objectid import ObjectId
2
from datetime import datetime, timedelta
2
from datetime import datetime, timedelta
3
from dtr.config import PythonPropertyReader
3
from dtr.config import PythonPropertyReader
4
from dtr.dao import FeaturedDeals, AppTransactions, AppOfferObj, Promotion
4
from dtr.dao import FeaturedDeals, AppTransactions, AppOfferObj, Promotion, NotificationCampaign
5
from dtr.storage import DataService
5
from dtr.storage import DataService
6
from dtr.storage.DataService import price_preferences, brand_preferences, \
6
from dtr.storage.DataService import price_preferences, brand_preferences, \
7
    user_actions, Brands, app_offers, approved_app_transactions, user_app_cashbacks, \
7
    user_actions, Brands, app_offers, approved_app_transactions, user_app_cashbacks, \
8
    user_app_installs, appmasters, notification_campaigns
8
    user_app_installs, appmasters, notification_campaigns
9
from dtr.storage.MemCache import MemCache
9
from dtr.storage.MemCache import MemCache
Line 58... Line 58...
58
                  'SkuSchemeDetails':'skuBundleId',
58
                  'SkuSchemeDetails':'skuBundleId',
59
                  'DealPoints':'skuBundleId',
59
                  'DealPoints':'skuBundleId',
60
                  'FeaturedDeals': 'skuBundleId'
60
                  'FeaturedDeals': 'skuBundleId'
61
                  }
61
                  }
62
 
62
 
63
class __NotificationCampaign:
-
 
64
    def __init__(self, campaignId, name, title, message, sql, url, created, expiresat, type, status, sendsms, messagetext, smsprocessed, notification_processed, notification_type):
-
 
65
        self._id = campaignId
-
 
66
        self.name = name
-
 
67
        self.title = title
-
 
68
        self.message = message
-
 
69
        self.sql = sql
-
 
70
        self.url = url
-
 
71
        self.created = created
-
 
72
        self.expiresat = expiresat
-
 
73
        self.type = type
-
 
74
        self.status = status
-
 
75
        self.sendsms = sendsms
-
 
76
        self.messagetext = messagetext 
-
 
77
        self.smsprocessed = smsprocessed
-
 
78
        self.notification_processed = notification_processed
-
 
79
        self.notification_type = notification_type 
-
 
80
        self.notification_long_text = None
-
 
81
 
63
 
82
def get_elastic_search_connection():
64
def get_elastic_search_connection():
83
    global es
65
    global es
84
    if es is None:
66
    if es is None:
85
        print "Establishing connection with elastic search %s host and port %s"%(elastic_search_host,elastic_search_port)
67
        print "Establishing connection with elastic search %s host and port %s"%(elastic_search_host,elastic_search_port)
Line 2259... Line 2241...
2259
    if len(max_id) ==0:
2241
    if len(max_id) ==0:
2260
        max_id = 0
2242
        max_id = 0
2261
    else:
2243
    else:
2262
        max_id = max_id[0]['_id']
2244
        max_id = max_id[0]['_id']
2263
    max_id = max_id +1
2245
    max_id = max_id +1
2264
    campaign = __NotificationCampaign(max_id, campaignName, title, message, "SELECT User.id from users User where User.id="+str(userIds[0]), url, to_java_date(datetime.now()), to_java_date(datetime.now()+timedelta(year=500)), notificationtype, 'active', sendsms, smstext, 0, 0, 'BATCH_CREDIT')
2246
    campaign = NotificationCampaign(max_id, campaignName, title, message, "SELECT User.id from users User where User.id="+str(userIds[0]), url, to_java_date(datetime.now()), to_java_date(datetime.now()+timedelta(year=500)), notificationtype, 'active', sendsms, smstext, 0, 0, 'BATCH_CREDIT')
2265
    get_mongo_connection(host=mongoHost).User.notificationcampaigns.insert(campaign.__dict__)
2247
    get_mongo_connection(host=mongoHost).User.notificationcampaigns.insert(campaign.__dict__)
2266
 
2248
 
2267
def getDummyDeals(categoryId, offset, limit):
2249
def getDummyDeals(categoryId, offset, limit):
2268
    outer_query = []
2250
    outer_query = []
2269
    outer_query.append({"showDeal":1})
2251
    outer_query.append({"showDeal":1})