Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitoring: Negative balance DB #1663

Open
tomsmith8 opened this issue May 21, 2024 · 2 comments
Open

Monitoring: Negative balance DB #1663

tomsmith8 opened this issue May 21, 2024 · 2 comments
Assignees

Comments

@tomsmith8
Copy link

tomsmith8 commented May 21, 2024

Task

  • Find all workspaces with negative balance
  • Nullify
  • Add function that checks balances in table for withdraw > deposit

SQL qeury:

@tomsmith8
Copy link
Author

Stub: Monitoring where withdraw > deposits balance

@tomsmith8 tomsmith8 assigned elraphty and unassigned tomsmith8 May 21, 2024
@fvalentiner
Copy link
Contributor

fvalentiner commented May 21, 2024

The SQL command to find workspaces with balances different than the sum of workspace transactions:

select
ph.workspace_uuid,
w.name,
SUM(case when payment_type = 'withdraw' THEN amount * -1 ELSE amount END) as amount,
bb.total_budget,
MAX(ph.updated) as last_transaction,
MIN(ph.updated) as first_transaction
from payment_histories as ph
inner join workspaces as w on w.uuid = ph.workspace_uuid
inner join bounty_budgets as bb on bb.workspace_uuid = ph.workspace_uuid
WHERE status = true
GROUP BY ph.workspace_uuid, w.name, bb.total_budget
HAVING SUM(case when payment_type = 'withdraw' THEN amount * -1 ELSE amount END) <> total_budget
ORDER by amount DESC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🧨 To Do
Development

No branches or pull requests

4 participants