diff --git a/cli/clickup-users.php b/cli/clickup-users.php index 3fedf68..24cd549 100755 --- a/cli/clickup-users.php +++ b/cli/clickup-users.php @@ -1,86 +1,86 @@ #!/usr/bin/php ClickUp bot # Copyright (C) 2023 Valerio Bozzolan, contributors # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . /** * Get ClickUp users */ // autoload libraries require __DIR__ . '/../autoload.php'; $cache = ClickUpPhabricatorCache::instance(); $populate = true; if( $populate ) { foreach( $cache->getIterableClickupTasks() as $clickup_task ) { $clickup_task_details = ClickUpAPI::queryTaskData( $clickup_task->id ); if( $clickup_task_details ) { echo "Import users from ClickUp Task {$clickup_task->id}\n"; } sleep( 1 ); } } foreach( $cache->getIterableClickupUsers() as $clickup_user ) { $clickup_user_id = $clickup_user->id; $phab_username = $cache->getClickUpUserPhabUsernameByID( $clickup_user_id ); $phab_phid = $cache->getClickUpUserPHIDByID( $clickup_user_id ); if( !$phab_username ) { $phab_username = readline("# Type Phabricator nickname of user {$clickup_user->username} (example: ciccio.franco): "); } if( !$phab_phid && $phab_username ) { $phab_user = PhabricatorAPI::getUserByUsername( $phab_username ); if( $phab_user ) { $phab_phid = $phab_user['phid']; $phab_username = $phab_user['fields']['username']; $cache ->lock() ->setClickUpUserPhabUsernameByID( $clickup_user_id, $phab_username ) ->setClickUpUserPHIDByID( $clickup_user_id, $phab_phid ) ->commit(); echo "# Saved\n\n"; } else { echo "# Not found\n\n"; } } } foreach( $cache->getIterableClickupUsers() as $clickup_user ) { $clickup_user_id = $clickup_user->id; $phab_username = $cache->getClickUpUserPhabUsernameByID( $clickup_user_id ); $phab_phid = $cache->getClickUpUserPHIDByID( $clickup_user_id ); echo $clickup_user->id; echo "\t|"; - echo $clickup_user->username; - echo "\t|"; echo $phab_username ? 'id CONNECTED TO PHAB' : 'id NOT CONNECTED TO PHAB'; + echo "\t|"; + echo $clickup_user->username; echo "\n"; }