def test_get_recommendable_item(self):
		fb = Random_Recommender()

		# inserting two items for domain1
		fb.set_recommendables( 1, { 'domainid' : 'domain1' } )
		fb.set_recommendables( 2, { 'domainid' : 'domain1' } )
		g = fb.get_recommendable_item( { 'domainid' : 'domain1' } )

		self.assertIn(int(g), (1,2), "fetched wrong recommendable item")

		# for this domain there is no way of recommending anything, because we don't have any items
		g = fb.get_recommendable_item( { 'domainid' : 'domain2' } )
		self.assertIsNone(g, "fetched wrong recommendable item")
Exemplo n.º 2
0
	def insertRecommendables(self, additional_filter, N1, N2):
		fb = Random_Recommender()


		for item_id in xrange(N1,N2):
			fb.set_recommendables( itemid = item_id, additional_filter = additional_filter )
Exemplo n.º 3
0
                fullParsedDataModel = FullContestMessageParser()
                fullParsedDataModel.parse(message)
                fullParsedDataModel.save()

                item_id = fullParsedDataModel.item_id

                if config_global.SAVE_RAW_JSON in backends:
                    raw = rawJsonModel(message, mode='redis')
                    raw.save()

                if config_global.SAVE_RANDOM_RECOMMENDER in backends:
                    fb = Random_Recommender()
                    domain_id = fullParsedDataModel.domain_id
                    ## todo the recommender has to decide on its own what to save and therefore save constraints, even though the constrain management should be centralized
                    #constraints = {'domainid': domain_id}
                    fb.set_recommendables(item_id, constraints)

            if api == 'orp':
                # todo throw not implemented error
                pass


            elif api == 'id_list': ## this for debugging purposes
                userid = message['userid']
                itemid = message['itemid']
                timestamp = message['timestamp']
                domainid = message['domainid']

                additional_filter = {'domainid': domainid}

                if config_global.SAVE_RANDOM_RECOMMENDER in backends: