def updateGood(self, good_key, json): session = models.getSession() good = session.query(models.Good).filter_by(key=good_key).first() if good: models.updateObjectWithJSON(good, json, ['key', 'application_key']) session.commit() return good
def setApplication(self, application_key, json): session = models.getSession() application = session.query(models.Application).filter_by(key=application_key).first() if application: models.updateObjectWithJSON(application, json, ['key']) session.commit() return application
def setABTest(self, application_key, json): session = models.getSession() abtest = self.getABTest(application_key) if abtest: newABTest = models.ABTest() newABTest.application_key = abtest.application_key newABTest.countryWhiteList = abtest.countryWhiteList newABTest.countryBlackList = abtest.countryBlackList newABTest.modulus = abtest.modulus newABTest.modulusLimit = abtest.modulusLimit newABTest.groupAPrices_key = abtest.groupAPrices_key newABTest.groupBPrices_key = abtest.groupBPrices_key # Check price foreign keys manually for prices in ['groupAPrices_key', 'groupBPrices_key']: if prices in json and json[prices] != None: count = session.query(models.Prices).join(models.Application).filter(models.Application.key == newABTest.application_key).filter(models.Prices.key==json[prices]).count() if count == 1: pass else: del json[prices] models.updateObjectWithJSON(newABTest, json, ['key']) session.add(newABTest) session.commit() return newABTest
def setCurrency(self, application_key, json): session = models.getSession() currencies = session.query(models.Currencies).join(models.Application).filter_by(key=application_key).first() if currencies: models.updateObjectWithJSON(currencies, json, ['key']) session.commit() return currencies
def setMetrics(self, application_key, json): session = models.getSession() metrics = session.query(models.Metrics).join(models.Application).filter(models.Application.key == application_key).first() if metrics: models.updateObjectWithJSON(metrics, json, ['key']) session.commit() return metrics
def updateGood(self, good_key, json): session = models.getSession() good = session.query(models.Good).filter_by(key=good_key).first() if good: models.updateObjectWithJSON(good, json, ['key', 'application_key']) session.commit() cacheObject(good) session.close() return good
def setApplication(self, application_key, json): session = models.getSession() application = session.query( models.Application).filter_by(key=application_key).first() if application: models.updateObjectWithJSON(application, json, ['key']) session.commit() cacheObject(application) session.close() return application
def setCurrency(self, application_key, json): session = models.getSession() currencies = session.query(models.Currencies).join( models.Application).filter_by(key=application_key).first() if currencies: models.updateObjectWithJSON(currencies, json, ['key']) session.commit() cacheObject(currencies) session.close() return currencies
def setMetrics(self, application_key, json): session = models.getSession() metrics = session.query(models.Metrics).join( models.Application).filter( models.Application.key == application_key).first() if metrics: models.updateObjectWithJSON(metrics, json, ['key']) session.commit() cacheObject(metrics) session.close() return metrics
def setABTest(self, application_key, json): session = models.getSession() abtest = self.getABTest(application_key) if abtest: newABTest = models.ABTest() newABTest.application_key = abtest.application_key newABTest.countryWhiteList = abtest.countryWhiteList newABTest.countryBlackList = abtest.countryBlackList newABTest.modulus = abtest.modulus newABTest.modulusLimit = abtest.modulusLimit newABTest.groupAPrices_key = abtest.groupAPrices_key newABTest.groupBPrices_key = abtest.groupBPrices_key # Check price foreign keys manually for prices in ['groupAPrices_key', 'groupBPrices_key']: if prices in json and json[prices] != None: count = session.query(models.Prices).join( models.Application).filter( models.Application.key == newABTest.application_key ).filter(models.Prices.key == json[prices]).count() if count == 1: pass else: del json[prices] models.updateObjectWithJSON(newABTest, json, ['key']) session.add(newABTest) session.commit() cacheObject(newABTest) session.close() return newABTest