| Line 20... |
Line 20... |
| 20 |
input_json = json.loads(response)
|
20 |
input_json = json.loads(response)
|
| 21 |
if input_json['status'].strip()=='ok' and input_json['message'] =="Success":
|
21 |
if input_json['status'].strip()=='ok' and input_json['message'] =="Success":
|
| 22 |
offers = (input_json['payload'])['offers']
|
22 |
offers = (input_json['payload'])['offers']
|
| 23 |
for offer in offers:
|
23 |
for offer in offers:
|
| 24 |
ACTIVE_OFFERS.append(str(offer['offerId']))
|
24 |
ACTIVE_OFFERS.append(str(offer['offerId']))
|
| - |
|
25 |
allExistingOffers = app_offers.query.all()
|
| - |
|
26 |
for existingOffer in allExistingOffers:
|
| - |
|
27 |
existingOffer.offer_active = False
|
| - |
|
28 |
existingOffer.show = False
|
| - |
|
29 |
session.commit()
|
| - |
|
30 |
|
| 25 |
for offer in offers:
|
31 |
for offer in offers:
|
| 26 |
fetchOfferDescriptionAndDump(offer)
|
32 |
fetchOfferDescriptionAndDump(offer)
|
| 27 |
|
33 |
|
| 28 |
|
34 |
|
| 29 |
def fetchOfferDescriptionAndDump(offer):
|
35 |
def fetchOfferDescriptionAndDump(offer):
|
| Line 57... |
Line 63... |
| 57 |
app_offer.package_name = offer.get('packageName')
|
63 |
app_offer.package_name = offer.get('packageName')
|
| 58 |
app_offer.description = input_json.get('description')
|
64 |
app_offer.description = input_json.get('description')
|
| 59 |
app_offer.shortDescription = offer.get('shortDesc')
|
65 |
app_offer.shortDescription = offer.get('shortDesc')
|
| 60 |
app_offer.longDescription = offer.get('longDesc')
|
66 |
app_offer.longDescription = offer.get('longDesc')
|
| 61 |
app_offer.link = offer.get('url')
|
67 |
app_offer.link = offer.get('url')
|
| 62 |
app_offer.offer_active = True
|
- |
|
| 63 |
app_offer.priority = 0
|
68 |
app_offer.priority = 0
|
| 64 |
app_offer.offerCategory = offer.get('offerCategory')
|
69 |
app_offer.offerCategory = offer.get('offerCategory')
|
| 65 |
app_offer.promoImage = input_json.get('promoImage')
|
70 |
app_offer.promoImage = input_json.get('promoImage')
|
| 66 |
app_offer.ratings = offer.get('appRating')
|
71 |
app_offer.ratings = offer.get('appRating')
|
| 67 |
app_offer.downloads = offer.get('appDownloads')
|
72 |
app_offer.downloads = offer.get('appDownloads')
|
| Line 69... |
Line 74... |
| 69 |
app_offer.appmaster_id = appMasterId
|
74 |
app_offer.appmaster_id = appMasterId
|
| 70 |
existingAppOffer = app_offers.query.filter(app_offers.affiliate_id==AFFILIATE_ID).filter(app_offers.package_name==offer['packageName']).filter(app_offers.show==True).first()
|
75 |
existingAppOffer = app_offers.query.filter(app_offers.affiliate_id==AFFILIATE_ID).filter(app_offers.package_name==offer['packageName']).filter(app_offers.show==True).first()
|
| 71 |
|
76 |
|
| 72 |
if existingAppOffer is None:
|
77 |
if existingAppOffer is None:
|
| 73 |
app_offer.show = True
|
78 |
app_offer.show = True
|
| - |
|
79 |
app_offer.offer_active = True
|
| 74 |
else:
|
80 |
else:
|
| 75 |
if existingAppOffer.affiliate_offer_id not in ACTIVE_OFFERS:
|
81 |
if existingAppOffer.affiliate_offer_id not in ACTIVE_OFFERS:
|
| 76 |
existingAppOffer.show = False
|
82 |
existingAppOffer.show = False
|
| 77 |
app_offer.show = True
|
83 |
app_offer.show = True
|
| - |
|
84 |
app_offer.offer_active = True
|
| 78 |
else:
|
85 |
else:
|
| 79 |
if existingAppOffer.offer_price <= float(offer['offerPrice']):
|
86 |
if existingAppOffer.offer_price <= float(offer['offerPrice']):
|
| 80 |
existingAppOffer.show = False
|
87 |
existingAppOffer.show = False
|
| 81 |
app_offer.show = True
|
88 |
app_offer.show = True
|
| - |
|
89 |
app_offer.offer_active = True
|
| 82 |
else:
|
90 |
else:
|
| 83 |
existingAppOffer.show = True
|
91 |
existingAppOffer.show = True
|
| 84 |
existingAppOffer.offer_active = True
|
92 |
existingAppOffer.offer_active = True
|
| 85 |
app_offer.show = False
|
93 |
app_offer.show = False
|
| 86 |
else:
|
94 |
else:
|
| Line 96... |
Line 104... |
| 96 |
app_offer.offerCategory = offer.get('offerCategory')
|
104 |
app_offer.offerCategory = offer.get('offerCategory')
|
| 97 |
app_offer.promoImage = input_json.get('promoImage')
|
105 |
app_offer.promoImage = input_json.get('promoImage')
|
| 98 |
app_offer.ratings = offer.get('appRating')
|
106 |
app_offer.ratings = offer.get('appRating')
|
| 99 |
app_offer.downloads = offer.get('appDownloads')
|
107 |
app_offer.downloads = offer.get('appDownloads')
|
| 100 |
app_offer.image_url = offer.get('iconUrl')
|
108 |
app_offer.image_url = offer.get('iconUrl')
|
| 101 |
app_offer.offer_active = True
|
- |
|
| 102 |
existingAppOffer = app_offers.query.filter(app_offers.affiliate_id==AFFILIATE_ID).filter(app_offers.package_name==offer['packageName']).filter(app_offers.show==True).first()
|
109 |
existingAppOffer = app_offers.query.filter(app_offers.affiliate_id==AFFILIATE_ID).filter(app_offers.package_name==offer['packageName']).filter(app_offers.show==True).first()
|
| 103 |
if existingAppOffer is None:
|
110 |
if existingAppOffer is None:
|
| 104 |
app_offer.show = True
|
111 |
app_offer.show = True
|
| - |
|
112 |
app_offer.offer_active = True
|
| 105 |
else:
|
113 |
else:
|
| 106 |
if existingAppOffer.affiliate_offer_id not in ACTIVE_OFFERS:
|
114 |
if existingAppOffer.affiliate_offer_id not in ACTIVE_OFFERS:
|
| 107 |
existingAppOffer.show = False
|
115 |
existingAppOffer.show = False
|
| 108 |
app_offer.show = True
|
116 |
app_offer.show = True
|
| - |
|
117 |
app_offer.offer_active = True
|
| 109 |
else:
|
118 |
else:
|
| 110 |
if existingAppOffer.offer_price <= float(offer['offerPrice']):
|
119 |
if existingAppOffer.offer_price <= float(offer['offerPrice']):
|
| 111 |
existingAppOffer.show = False
|
120 |
existingAppOffer.show = False
|
| 112 |
app_offer.show = True
|
121 |
app_offer.show = True
|
| - |
|
122 |
app_offer.offer_active = True
|
| 113 |
else:
|
123 |
else:
|
| 114 |
existingAppOffer.show = True
|
124 |
existingAppOffer.show = True
|
| 115 |
existingAppOffer.offer_active
|
125 |
existingAppOffer.offer_active = True
|
| 116 |
app_offer.show = False
|
126 |
app_offer.show = False
|
| 117 |
|
127 |
|
| 118 |
'''
|
128 |
'''
|
| 119 |
app_offer = app_offers.get_by(affiliate_id=AFFILIATE_ID, affiliate_offer_id=offer['offerId'], package_name=offer['package_name'])
|
129 |
app_offer = app_offers.get_by(affiliate_id=AFFILIATE_ID, affiliate_offer_id=offer['offerId'], package_name=offer['package_name'])
|
| 120 |
|
130 |
|