Skip to content

Commit

Permalink
Add --import flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Aug 26, 2024
1 parent 71af9fb commit 573ac15
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion batch/updatecontactdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class UpdateContactdb_Batch {
/** @var bool */
public $authors;
/** @var bool */
public $import;
/** @var bool */
public $metadata;
/** @var bool */
public $verbose;
Expand All @@ -39,6 +41,7 @@ function __construct(Conf $conf, $arg) {
$this->collaborators = isset($arg["collaborators"]);
$this->authors = isset($arg["authors"]);
$this->metadata = isset($arg["metadata"]);
$this->import = isset($arg["import"]);
$this->verbose = isset($arg["V"]);
if (!$this->papers && !$this->users && !$this->collaborators && !$this->authors && !$this->metadata) {
$this->papers = $this->users = true;
Expand Down Expand Up @@ -271,6 +274,19 @@ private function run_papers() {
}
}

private function run_import() {
$result = $this->conf->qe("select * from ContactInfo where (firstName='' or lastName='' or affiliation='' or coalesce(collaborators,'')='' or coalesce(country,'')='' or coalesce(orcid,'')='')");
$uset = ContactSet::make_result($result, $this->conf);
foreach ($uset as $u) {
if (($cdbu = $u->cdb_user())) {
$u->import_prop($cdbu, 2);
if ($u->prop_changed()) {
$u->save_prop();
}
}
}
}

/** @return int */
function run() {
if ($this->metadata) {
Expand All @@ -288,6 +304,9 @@ function run() {
if ($this->papers) {
$this->run_papers();
}
if ($this->import) {
$this->run_import();
}
return 0;
}

Expand All @@ -303,9 +322,10 @@ static function make_args($argv) {
"collaborators",
"authors",
"metadata",
"import",
"V,verbose"
)->description("Update HotCRP contactdb for a conference.
Usage: php batch/updatecontactdb.php [-n CONFID | --config CONFIG] [--papers] [--users] [--collaborators] [--authors]")
Usage: php batch/updatecontactdb.php [-n CONFID | --config CONFIG] [--papers] [--users] [--collaborators] [--authors] [--import]")
->helpopt("help")
->maxarg(0)
->parse($argv);
Expand Down

0 comments on commit 573ac15

Please sign in to comment.