async def initialize(self): connection = await init_neptune_connection() async with connection: g = Graph().traversal().withRemote(connection) data = await (g.V().hasLabel("transientId").coin(COIN).limit( ARG_COLLECTION).group().by().by( outE("visited").coin(COIN).inV().in_("links_to").out( "links_to").coin(COIN).path().by(values("uid")).by( values("ts")).by(values("url")).by( values("url")).by(values("url"))).select( Column.values).unfold()).toList() self.args = [{ "transient_id": result[0], "website_url": result[2], "thank_you_page_url": result[4], "since": result[1] - timedelta(days=random.randint(30, 60)), "min_visited_count": random.randint(2, 5) } for result in data if result]
async def initialize(self): connection = await init_neptune_connection() async with connection: g = Graph().traversal().withRemote(connection) most_visited_websites = await get_most_active_websites(g) data = await (g.V(most_visited_websites).group().by().by( inE().hasLabel("visited").coin(COIN).inV().in_( "links_to").out("links_to").coin(COIN).path().by( values("url")) # visited website .by(values("ts")) # timestamp .by(values("url")) # visited website .by(values("url")) # root website .by(values("url").limit(1)) # thank you page ).select(Column.values).unfold()).toList() self.args = [{ "website_url": result[0], "thank_you_page_url": result[4], "since": result[1] - timedelta(days=random.randint(30, 60)), "min_visited_count": random.randint(2, 5) } for result in data]
async def test_metas(app, place, remote_connection): g = Graph().traversal().withRemote(remote_connection) session = await app.session() place.zipcode = 98402 place.historical_name = ['Detroit'] place.historical_name('Detroit').notes = 'rock city' place.historical_name('Detroit').year = 1900 place.historical_name.append('Other') place.historical_name[-1].notes = 'unknown' place.historical_name[-1].year = 1700 detroit = await session.save(place) dprops = await g.V(detroit.id).properties().toList() assert len(dprops) == 4 trav = g.V(detroit.id).properties('historical_name').valueMap(True) dmetas = await trav.toList() assert dmetas[0]['value'] == 'Detroit' assert dmetas[0]['notes'] == 'rock city' assert dmetas[0]['year'] == 1900 assert dmetas[1]['value'] == 'Other' assert dmetas[1]['notes'] == 'unknown' assert dmetas[1]['year'] == 1700 new_session = await app.session() new_detroit = await new_session.g.V(detroit.id).next() assert new_detroit.zipcode == detroit.zipcode assert new_detroit.historical_name[-1].value == detroit.historical_name[-1].value assert new_detroit.historical_name[-1].notes == detroit.historical_name[-1].notes assert new_detroit.historical_name[-1].year == detroit.historical_name[-1].year assert new_detroit.historical_name[0].value == detroit.historical_name[0].value assert new_detroit.historical_name[0].notes == detroit.historical_name[0].notes assert new_detroit.historical_name[0].year == detroit.historical_name[0].year await remote_connection.close() await app.close()
async def initialize(self): connection = await init_neptune_connection() async with connection: g = Graph().traversal().withRemote(connection) websites = await (g.V().hasLabel("website").coin(COIN).limit( ARG_COLLECTION).toList()) self.args = [{"website_url": website} for website in websites]