@@ -313,6 +313,108 @@ end
313
313
314
314
Logger . info ( "Contract: #{ AlgoraWeb.Endpoint . url ( ) } /org/#{ pied_piper . handle } /contracts/#{ initial_contract . id } " )
315
315
316
+ big_head =
317
+ upsert! (
318
+ :user ,
319
+ [ :email ] ,
320
+ % {
321
+
322
+ display_name: "Nelson Bighetti" ,
323
+ handle: "bighead" ,
324
+ bio: "Former Hooli executive. Accidental tech success. Stanford President." ,
325
+ avatar_url: "https://algora.io/asset/storage/v1/object/public/mock/bighead.jpg" ,
326
+ tech_stack: [ "Python" , "JavaScript" ] ,
327
+ country: "IT" ,
328
+ hourly_rate_min: Money . new! ( 150 , :USD ) ,
329
+ hourly_rate_max: Money . new! ( 200 , :USD ) ,
330
+ hours_per_week: 25
331
+ }
332
+ )
333
+
334
+ jian_yang =
335
+ upsert! (
336
+ :user ,
337
+ [ :email ] ,
338
+ % {
339
+
340
+ display_name: "Jian Yang" ,
341
+ handle: "jianyang" ,
342
+ bio: "App developer. Creator of SeeFood and Smokation." ,
343
+ avatar_url: "https://algora.io/asset/storage/v1/object/public/mock/jianyang.jpg" ,
344
+ tech_stack: [ "Swift" , "Python" , "TensorFlow" ] ,
345
+ country: "HK" ,
346
+ hourly_rate_min: Money . new! ( 125 , :USD ) ,
347
+ hourly_rate_max: Money . new! ( 175 , :USD ) ,
348
+ hours_per_week: 35
349
+ }
350
+ )
351
+
352
+ john =
353
+ upsert! (
354
+ :user ,
355
+ [ :email ] ,
356
+ % {
357
+
358
+ display_name: "John Stafford" ,
359
+ handle: "john" ,
360
+ bio: "Datacenter infrastructure expert. Rack space optimization specialist." ,
361
+ avatar_url: "https://algora.io/asset/storage/v1/object/public/mock/john.png" ,
362
+ tech_stack: [ "Perl" , "Terraform" , "C++" , "C" ] ,
363
+ country: "GB" ,
364
+ hourly_rate_min: Money . new! ( 140 , :USD ) ,
365
+ hourly_rate_max: Money . new! ( 190 , :USD ) ,
366
+ hours_per_week: 40
367
+ }
368
+ )
369
+
370
+ aly =
371
+ upsert! (
372
+ :user ,
373
+ [ :email ] ,
374
+ % {
375
+
376
+ display_name: "Aly Dutta" ,
377
+ handle: "aly" ,
378
+ bio: "Former Hooli engineer. Expert in distributed systems and scalability." ,
379
+ avatar_url: "https://algora.io/asset/storage/v1/object/public/mock/aly.png" ,
380
+ tech_stack: [ "Java" , "Kotlin" , "Go" ] ,
381
+ country: "IN" ,
382
+ hourly_rate_min: Money . new! ( 160 , :USD ) ,
383
+ hourly_rate_max: Money . new! ( 220 , :USD ) ,
384
+ hours_per_week: 35
385
+ }
386
+ )
387
+
388
+ for user <- [ aly , big_head , jian_yang , john ] do
389
+ debit_id = Nanoid . generate ( )
390
+ credit_id = Nanoid . generate ( )
391
+ amount = Money . new! ( Enum . random ( 1 .. 10 ) * 10_000 , :USD )
392
+
393
+ Repo . transact ( fn ->
394
+ insert! ( :transaction , % {
395
+ id: debit_id ,
396
+ linked_transaction_id: credit_id ,
397
+ type: :debit ,
398
+ status: :succeeded ,
399
+ net_amount: amount ,
400
+ user_id: pied_piper . id ,
401
+ succeeded_at: days_from_now ( 0 )
402
+ } )
403
+
404
+ insert! ( :transaction , % {
405
+ id: credit_id ,
406
+ linked_transaction_id: debit_id ,
407
+ type: :credit ,
408
+ status: :succeeded ,
409
+ net_amount: amount ,
410
+ user_id: user . id ,
411
+ succeeded_at: days_from_now ( 0 )
412
+ } )
413
+
414
+ { :ok , :ok }
415
+ end )
416
+ end
417
+
316
418
repos = [
317
419
{
318
420
"middle-out" ,
@@ -431,153 +533,57 @@ for {repo_name, issues} <- repos do
431
533
url: "https://github.com/piedpiper/#{ repo_name } /pull/#{ index } "
432
534
} )
433
535
434
- claim =
435
- insert! ( :claim , % {
436
- user_id: carver . id ,
437
- target_id: issue . id ,
438
- source_id: pull_request . id ,
439
- type: :pull_request ,
440
- status: if ( paid , do: :approved , else: :pending ) ,
441
- url: "https://github.com/piedpiper/#{ repo_name } /pull/#{ index } "
442
- } )
443
-
444
- # Create transaction pairs for paid claims
445
- if paid do
446
- debit_id = Nanoid . generate ( )
447
- credit_id = Nanoid . generate ( )
448
-
449
- Repo . transact ( fn ->
450
- insert! ( :transaction , % {
451
- id: debit_id ,
452
- linked_transaction_id: credit_id ,
453
- bounty_id: bounty . id ,
454
- type: :debit ,
455
- status: :succeeded ,
456
- net_amount: amount ,
457
- user_id: pied_piper . id ,
458
- succeeded_at: claim . inserted_at
459
- } )
460
-
461
- insert! ( :transaction , % {
462
- id: credit_id ,
463
- linked_transaction_id: debit_id ,
464
- bounty_id: bounty . id ,
465
- type: :credit ,
466
- status: :succeeded ,
467
- net_amount: amount ,
468
- user_id: carver . id ,
469
- succeeded_at: claim . inserted_at
536
+ group_id = Nanoid . generate ( )
537
+
538
+ for { user , share } <- [ { carver , Decimal . new ( "0.5" ) } , { aly , Decimal . new ( "0.3" ) } , { big_head , Decimal . new ( "0.2" ) } ] do
539
+ claim =
540
+ insert! ( :claim , % {
541
+ group_id: group_id ,
542
+ group_share: share ,
543
+ user_id: user . id ,
544
+ target_id: issue . id ,
545
+ source_id: pull_request . id ,
546
+ type: :pull_request ,
547
+ status: if ( paid , do: :approved , else: :pending ) ,
548
+ url: "https://github.com/piedpiper/#{ repo_name } /pull/#{ index } "
470
549
} )
471
550
472
- { :ok , :ok }
473
- end )
551
+ # Create transaction pairs for paid claims
552
+ if paid do
553
+ debit_id = Nanoid . generate ( )
554
+ credit_id = Nanoid . generate ( )
555
+
556
+ Repo . transact ( fn ->
557
+ insert! ( :transaction , % {
558
+ id: debit_id ,
559
+ linked_transaction_id: credit_id ,
560
+ bounty_id: bounty . id ,
561
+ type: :debit ,
562
+ status: :succeeded ,
563
+ net_amount: Money . mult! ( amount , share ) ,
564
+ user_id: pied_piper . id ,
565
+ succeeded_at: claim . inserted_at
566
+ } )
567
+
568
+ insert! ( :transaction , % {
569
+ id: credit_id ,
570
+ linked_transaction_id: debit_id ,
571
+ bounty_id: bounty . id ,
572
+ type: :credit ,
573
+ status: :succeeded ,
574
+ net_amount: Money . mult! ( amount , share ) ,
575
+ user_id: user . id ,
576
+ succeeded_at: claim . inserted_at
577
+ } )
578
+
579
+ { :ok , :ok }
580
+ end )
581
+ end
474
582
end
475
583
end
476
584
end
477
585
end
478
586
479
- big_head =
480
- upsert! (
481
- :user ,
482
- [ :email ] ,
483
- % {
484
-
485
- display_name: "Nelson Bighetti" ,
486
- handle: "bighead" ,
487
- bio: "Former Hooli executive. Accidental tech success. Stanford President." ,
488
- avatar_url: "https://algora.io/asset/storage/v1/object/public/mock/bighead.jpg" ,
489
- tech_stack: [ "Python" , "JavaScript" ] ,
490
- country: "IT" ,
491
- hourly_rate_min: Money . new! ( 150 , :USD ) ,
492
- hourly_rate_max: Money . new! ( 200 , :USD ) ,
493
- hours_per_week: 25
494
- }
495
- )
496
-
497
- jian_yang =
498
- upsert! (
499
- :user ,
500
- [ :email ] ,
501
- % {
502
-
503
- display_name: "Jian Yang" ,
504
- handle: "jianyang" ,
505
- bio: "App developer. Creator of SeeFood and Smokation." ,
506
- avatar_url: "https://algora.io/asset/storage/v1/object/public/mock/jianyang.jpg" ,
507
- tech_stack: [ "Swift" , "Python" , "TensorFlow" ] ,
508
- country: "HK" ,
509
- hourly_rate_min: Money . new! ( 125 , :USD ) ,
510
- hourly_rate_max: Money . new! ( 175 , :USD ) ,
511
- hours_per_week: 35
512
- }
513
- )
514
-
515
- john =
516
- upsert! (
517
- :user ,
518
- [ :email ] ,
519
- % {
520
-
521
- display_name: "John Stafford" ,
522
- handle: "john" ,
523
- bio: "Datacenter infrastructure expert. Rack space optimization specialist." ,
524
- avatar_url: "https://algora.io/asset/storage/v1/object/public/mock/john.png" ,
525
- tech_stack: [ "Perl" , "Terraform" , "C++" , "C" ] ,
526
- country: "GB" ,
527
- hourly_rate_min: Money . new! ( 140 , :USD ) ,
528
- hourly_rate_max: Money . new! ( 190 , :USD ) ,
529
- hours_per_week: 40
530
- }
531
- )
532
-
533
- aly =
534
- upsert! (
535
- :user ,
536
- [ :email ] ,
537
- % {
538
-
539
- display_name: "Aly Dutta" ,
540
- handle: "aly" ,
541
- bio: "Former Hooli engineer. Expert in distributed systems and scalability." ,
542
- avatar_url: "https://algora.io/asset/storage/v1/object/public/mock/aly.png" ,
543
- tech_stack: [ "Java" , "Kotlin" , "Go" ] ,
544
- country: "IN" ,
545
- hourly_rate_min: Money . new! ( 160 , :USD ) ,
546
- hourly_rate_max: Money . new! ( 220 , :USD ) ,
547
- hours_per_week: 35
548
- }
549
- )
550
-
551
- for user <- [ aly , big_head , jian_yang , john ] do
552
- debit_id = Nanoid . generate ( )
553
- credit_id = Nanoid . generate ( )
554
- amount = Money . new! ( Enum . random ( 1 .. 10 ) * 10_000 , :USD )
555
-
556
- Repo . transact ( fn ->
557
- insert! ( :transaction , % {
558
- id: debit_id ,
559
- linked_transaction_id: credit_id ,
560
- type: :debit ,
561
- status: :succeeded ,
562
- net_amount: amount ,
563
- user_id: pied_piper . id ,
564
- succeeded_at: days_from_now ( 0 )
565
- } )
566
-
567
- insert! ( :transaction , % {
568
- id: credit_id ,
569
- linked_transaction_id: debit_id ,
570
- type: :credit ,
571
- status: :succeeded ,
572
- net_amount: amount ,
573
- user_id: user . id ,
574
- succeeded_at: days_from_now ( 0 )
575
- } )
576
-
577
- { :ok , :ok }
578
- end )
579
- end
580
-
581
587
reviews = [
582
588
{ richard , carver , - 1 ,
583
589
"His cloud architecture is... unconventional, but it works. Like, really works. Our servers haven't crashed in weeks. Just wish he'd document things better." } ,
0 commit comments