Hello,
Here is what I did:
Step 1: Fetched all attacks via v2 Attack and _meta prev. link.
Step 2: .json to .db (don't add if violating prim key) <- maybe something went wrong here... (but let's pretend it didn't)
Step 3:
select attacker_id and sum( respect_gain) as Score
where attacker_faction_id = 12345 and defender_faction_id = 23456 and is_ranked_war = "true"
group by attacker_id
Now I should have the scores for the ranked war, shouldn't I?
However, after comparing, I can say, that I haven't for all. For some I had the correct score for others I had not.
What was my intention: I wanted to make a more sophisticated payout-calculator than those, that are available atm.
Edit: I did the calculation with the .json (I removed double entries) and came to the same scores. So there are now four options:
a) Something is wrong with with the api .
b) Something is wrong with how you calculate the score.
c) You calculate the score in another way. (But your formular is the correct one)
d) I made a misstake, I haven't found yet.
Edit 2: I am pretty sure https://api.torn.com/v2/faction/attacks somehow doesn't fetch all attacks.
I used this code to fetch all attacks: https://we.tl/t-DaVKcUdvsH
Edit 3: I could confirm my suspicion. I used attacksfull to fetch the attacks and calculate the score and now I came to the war score.