Hi Gary
Thank for the reply. no i'm not 100% if a stored custom procedure is the way to go at the moment it's a proof of concept sys.
The idea is each group node has a property "query" that holds a query matching the cretaria of being a part of it's group.
such as :
MATCH (aca:AccountAction)<-[:PLAYER_ACCOUNT_ACTION]-(aaha:AccountActionHourlyAggregate)<-[paat:PLAYER_ACCOUNT_ACTION_TIME]-(aada:AccountActionDailyAggregate)<-[paad:PLAYER_ACCOUNT_ACTION_DATE]-(player:Player)
WHERE date(paad.date) >= date("2024-02-01") AND date(paad.date) <= date("2024-02-15")
WITH player, COLLECT({action: aca, amount: aca.amount}) AS actions
WITH player, REDUCE(total = 0, action IN actions | total + action.amount) AS totalAmount
WHERE totalAmount == 100
when events are triggered on the db such as an AccountAction creation a trigger will send the playerId and the action type to the procedure, the procedure then runs all the group nodes query against the player to see if he needs to be added or removed from a group. A cron job would not be able to do this as it needs to be in real time (give or take a few minutes). I think i'm dealing with about 500,000 hits every 5 seconds it's the 1st time with neo4j but was told it would be a good fit (as it would be used for other bits).
As for the problem I'm convinced it must be how the code interacts in the transaction as its a long query to create the AccountAction :::
MERGE (aaha:AccountActionHourlyAggregate {id:2024020209})
ON CREATE SET aaha.id = 2024020209
,aaha.playerId = 353453
MERGE (aada:AccountActionDailyAggregate {id: 20240202})
ON CREATE SET aada.id = 20240202
,aada.playerId = 353453
MERGE (player:Player {playerId: 353453})
MERGE (aaha)<-[rel1:PLAYER_ACCOUNT_ACTION_TIME]-(aada)
ON CREATE SET rel1.time = datetime("2024-02-02T09:00:43Z")
MERGE (aada)<-[rel2:PLAYER_ACCOUNT_ACTION_DATE]-(player)
ON CREATE SET rel2.date = date("2024-02-02")
WITH aaha
MERGE (aca:AccountAction {accountActionId:74494 })
ON CREATE
SET aca.accountActionId = 74494,
aca.accHistId= 200007303839,
aca.accountActionId= 74494,
aca.actionId= 22,
aca.playerId= 353453,
aca.amount= 50,
aca.amountInOriginalCurrency= 51.0,
aca.transactionCount= 1,
aca.odds= 0,
aca.bets= 0,
aca.internalRef= 'ST-2436535743454-200',
aca.externalRef= 'd-cypAutoTrx2023-11-01T10:55:43.069Z_57_70',
aca.extCode= 'cypAutoRound2023-11-01T10:55:43.069Z_57_70',
aca.aca.aca.aca.aca.aca.text= '',
aca.paymentMethodId= 0,
aca.gameId= 15775,
aca.currencyId= 1,
aca.accStatusId= 11,
aca.paymentProviderId= 0,
aca.time= '2024-02-02T09:00:43.000Z'
WITH aaha,aca
WITH aca,aaha
MATCH (n:AccountActionType)
WHERE n.accountActionTypeId = 22
MERGE (aca)-[:ACCOUNT_ACTION_TYPE]->(n)
WITH aca,aaha
MATCH (n:AccountStatus)
WHERE n.accountStatusId = 11
MERGE (aca)-[:ACCOUNT_STATUS]->(n)
WITH aca,aaha
MATCH (n:Currency)
WHERE n.currencyId = 1
MERGE (aca)-[:CURRENCY]->(n)
WITH aca,aaha
MATCH (n:PaymentMethod)
WHERE n.paymentMethodId = 0
MERGE (aca)-[:PAYMENT_METHOD]->(n)
WITH aca,aaha
MATCH (n:PaymentGroup)
WHERE n.paymentGroupId = 0
MERGE (aca)-[:PAYMENT_PROVIDER]->(n)
WITH aca,aaha
MERGE (aaha)-[:PLAYER_ACCOUNT_ACTION]->(aca)
RETURN aca
I'll try to strip it back to "CREATE (accountAction:AccountAction {playerId: 2345})" in a test to see what happens as for the code ::
public String saveAccountDepositActionAndRelationships(String inAccountActionCreateStr) {
try (Session session = sessionDriver.session()) {
Transaction tx = session.beginTransaction();
var result = tx.run(inAccountActionCreateStr);
tx.commit();
}
return "ok";
}
the input being a string of that very long query!