@@ -469,6 +469,36 @@ void DatabasePromotion::UpdateStatus(
469
469
ledger_->RunDBTransaction (std::move (transaction), transaction_callback);
470
470
}
471
471
472
+ void DatabasePromotion::UpdateRecordsStatus (
473
+ const std::vector<std::string>& ids,
474
+ const ledger::PromotionStatus status,
475
+ ledger::ResultCallback callback) {
476
+ if (ids.empty ()) {
477
+ callback (ledger::Result::LEDGER_ERROR);
478
+ return ;
479
+ }
480
+
481
+ const std::string query = base::StringPrintf (
482
+ " UPDATE %s SET status = ? WHERE promotion_id IN (%s)" ,
483
+ kTableName ,
484
+ GenerateStringInCase (ids).c_str ());
485
+
486
+ auto transaction = ledger::DBTransaction::New ();
487
+ auto command = ledger::DBCommand::New ();
488
+ command->type = ledger::DBCommand::Type::RUN;
489
+ command->command = query;
490
+
491
+ BindInt (command.get (), 0 , static_cast <int >(status));
492
+
493
+ transaction->commands .push_back (std::move (command));
494
+
495
+ auto transaction_callback = std::bind (&OnResultCallback,
496
+ _1,
497
+ callback);
498
+
499
+ ledger_->RunDBTransaction (std::move (transaction), transaction_callback);
500
+ }
501
+
472
502
void DatabasePromotion::CredentialCompleted (
473
503
const std::string& promotion_id,
474
504
ledger::ResultCallback callback) {
@@ -623,4 +653,27 @@ void DatabasePromotion::GetRecordsByType(
623
653
ledger_->RunDBTransaction (std::move (transaction), transaction_callback);
624
654
}
625
655
656
+ void DatabasePromotion::UpdateRecordsBlankPublicKey (
657
+ const std::vector<std::string>& ids,
658
+ ledger::ResultCallback callback) {
659
+ const std::string query = base::StringPrintf (
660
+ " UPDATE %s as p SET public_keys = "
661
+ " (SELECT PRINTF('[\" %%s\" ]', public_key) FROM creds_batch as cb "
662
+ " WHERE cb.trigger_id = p.promotion_id) WHERE p.promotion_id IN (%s)" ,
663
+ kTableName ,
664
+ GenerateStringInCase (ids).c_str ());
665
+
666
+ auto transaction = ledger::DBTransaction::New ();
667
+ auto command = ledger::DBCommand::New ();
668
+ command->type = ledger::DBCommand::Type::EXECUTE;
669
+ command->command = query;
670
+ transaction->commands .push_back (std::move (command));
671
+
672
+ auto transaction_callback = std::bind (&OnResultCallback,
673
+ _1,
674
+ callback);
675
+
676
+ ledger_->RunDBTransaction (std::move (transaction), transaction_callback);
677
+ }
678
+
626
679
} // namespace braveledger_database
0 commit comments