diff --git a/cli/clickup-folders.php b/cli/clickup-folders.php index 6ba32fa..0c58070 100755 --- a/cli/clickup-folders.php +++ b/cli/clickup-folders.php @@ -1,76 +1,90 @@ #!/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 folders */ // autoload libraries require __DIR__ . '/../autoload.php'; $cache = ClickUpPhabricatorCache::instance(); // import all ClickUp Folders from all Spaces $clickup_spaces = ClickUpAPI::getSpaces(); foreach( $clickup_spaces as $space ) { // $space->id // $space->name // save each folder in the cache $cache->newlock(); $folders = ClickUpAPI::getSpaceFolders( $space->id ); foreach( $folders as $folder ) { // $folder->id // $folder->name $cache->importClickupFolder( $folder ); } $cache->save(); } // loop cached folders foreach( $cache->getClickUpFolders() as $folder ) { $phab_tag_id = $cache->getPhabricatorTagIDFromClickupFolderID( $folder->id ); $phab_tag_phid = $cache->getPhabricatorTagPHIDFromClickupFolderID( $folder->id ); if( $phab_tag_id ) { // find fresh project from its slug $phab_project = PhabricatorAPI::querySingle( 'project.search', [ 'constraints' => [ 'slugs' => [ $phab_tag_id, ] ], ] ); - // force association to this ClickUp folder + // associate the ClickUp folder to the Phabricator Tag PHID $cache ->newlock() ->associateClickupFolderIDPhabricatorPHID( $folder->id, $phab_project['phid'] ) ->save(); + + /* + // find columns from this project + $phab_columns = PhabricatorAPI::query( 'project.column.search', [ + 'constraints' => [ + 'projects' => [ $phab_project['phid'] ], + ], + ] ); + + $cache->newlock(); + foreach( $phab_columns['data'] as $phab_column ) { + $cache->associateClickupFolderIDPhabricatorColumnPHID( $folder->id, $phab_column['phid'] ); + } + $cache->save(); + */ } $phab_tag_id_msg = $phab_tag_id ? "HAS Phab ID" : "MISSING Phab ID"; + // print something nice to see echo $folder->id . "\t|" . $phab_tag_id_msg . "\t|" . $folder->name . "\n"; - - }