@@ -515,13 +515,18 @@ defmodule DatabaseMigration do
515515 github_user = find_by_index ( db , "GithubUser" , "id" , claim [ "github_user_id" ] )
516516 bounty = find_by_index ( db , "Bounty" , "id" , claim [ "bounty_id" ] )
517517 owner = find_by_index ( db , "_MergedUser" , "id" , bounty [ "org_id" ] )
518+ bounty_charge = find_by_index ( db , "BountyCharge" , "id" , row [ "bounty_charge_id" ] )
518519 user_id = or_else ( github_user [ "user_id" ] , github_user [ "id" ] )
519520 amount = Money . from_integer ( String . to_integer ( row [ "amount" ] ) , row [ "currency" ] )
520521
521522 if ! bounty do
522523 raise "Bounty not found: #{ inspect ( row ) } "
523524 end
524525
526+ if ! bounty_charge do
527+ raise "BountyCharge not found: #{ inspect ( row ) } "
528+ end
529+
525530 if nullish? ( user_id ) do
526531 raise "User not found: #{ inspect ( row ) } "
527532 end
@@ -530,7 +535,7 @@ defmodule DatabaseMigration do
530535 raise "Owner not found: #{ inspect ( row ) } "
531536 end
532537
533- if bounty [ "type" ] == "tip" do
538+ if bounty [ "type" ] == "tip" and ! nullish? ( bounty_charge [ "succeeded_at" ] ) do
534539 % {
535540 "id" => bounty [ "id" ] <> user_id ,
536541 "amount" => amount ,
@@ -570,35 +575,37 @@ defmodule DatabaseMigration do
570575 raise "BountyCharge not found: #{ inspect ( row ) } "
571576 end
572577
573- Enum . reject (
574- [
575- maybe_create_transaction ( "debit" , % {
576- bounty_charge: bounty_charge ,
577- bounty_transfer: row ,
578- bounty: bounty ,
579- claim: claim ,
580- org: org ,
581- user_id: user_id
582- } ) ,
583- maybe_create_transaction ( "credit" , % {
584- bounty_charge: bounty_charge ,
585- bounty_transfer: row ,
586- bounty: bounty ,
587- claim: claim ,
588- org: org ,
589- user_id: user_id
590- } ) ,
591- maybe_create_transaction ( "transfer" , % {
592- bounty_charge: bounty_charge ,
593- bounty_transfer: row ,
594- bounty: bounty ,
595- claim: claim ,
596- org: org ,
597- user_id: user_id
598- } )
599- ] ,
600- & is_nil / 1
601- )
578+ if ! nullish? ( bounty_charge [ "succeeded_at" ] ) do
579+ Enum . reject (
580+ [
581+ maybe_create_transaction ( "debit" , % {
582+ bounty_charge: bounty_charge ,
583+ bounty_transfer: row ,
584+ bounty: bounty ,
585+ claim: claim ,
586+ org: org ,
587+ user_id: user_id
588+ } ) ,
589+ maybe_create_transaction ( "credit" , % {
590+ bounty_charge: bounty_charge ,
591+ bounty_transfer: row ,
592+ bounty: bounty ,
593+ claim: claim ,
594+ org: org ,
595+ user_id: user_id
596+ } ) ,
597+ maybe_create_transaction ( "transfer" , % {
598+ bounty_charge: bounty_charge ,
599+ bounty_transfer: row ,
600+ bounty: bounty ,
601+ claim: claim ,
602+ org: org ,
603+ user_id: user_id
604+ } )
605+ ] ,
606+ & is_nil / 1
607+ )
608+ end
602609 end
603610
604611 defp transform ( { "OrgBalanceTransaction" , Transaction } , row , db ) do
0 commit comments