From 397645b2731be94d313252c55baf9fdb21d1346c Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 8 May 2018 11:24:10 -0700 Subject: [PATCH] Export task point values as double, not int Summary: See . We currently export the Maniphest "points" field as an integer, but allow it to accept decimal values (e.g. "6.25"). Also fix a bug where we wouldn't roll over from "..., X, Y, Z, AA, AB, ..." correctly for Excel column names if sheet had more than 26 columns. Test Plan: - Set a task point value to 6.25. - Exported to text, JSON, XLS. - Saw 6.25 represented accurately in exports. - Exported an excel sheet with 27+ columns. - Manually printed the first 200 column names to check that the algorithm looks correct. Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D19434 --- src/__phutil_library_map__.php | 2 ++ .../query/ManiphestTaskSearchEngine.php | 2 +- .../field/PhabricatorDoubleExportField.php | 25 +++++++++++++++++++ .../format/PhabricatorExcelExportFormat.php | 6 ++++- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/infrastructure/export/field/PhabricatorDoubleExportField.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 85ae70c3e3..6c91c0f0a4 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2882,6 +2882,7 @@ phutil_register_library_map(array( 'PhabricatorDocumentRef' => 'applications/files/document/PhabricatorDocumentRef.php', 'PhabricatorDocumentRenderingEngine' => 'applications/files/document/render/PhabricatorDocumentRenderingEngine.php', 'PhabricatorDoorkeeperApplication' => 'applications/doorkeeper/application/PhabricatorDoorkeeperApplication.php', + 'PhabricatorDoubleExportField' => 'infrastructure/export/field/PhabricatorDoubleExportField.php', 'PhabricatorDraft' => 'applications/draft/storage/PhabricatorDraft.php', 'PhabricatorDraftDAO' => 'applications/draft/storage/PhabricatorDraftDAO.php', 'PhabricatorDraftEngine' => 'applications/transactions/draft/PhabricatorDraftEngine.php', @@ -8540,6 +8541,7 @@ phutil_register_library_map(array( 'PhabricatorDocumentRef' => 'Phobject', 'PhabricatorDocumentRenderingEngine' => 'Phobject', 'PhabricatorDoorkeeperApplication' => 'PhabricatorApplication', + 'PhabricatorDoubleExportField' => 'PhabricatorExportField', 'PhabricatorDraft' => 'PhabricatorDraftDAO', 'PhabricatorDraftDAO' => 'PhabricatorLiskDAO', 'PhabricatorDraftEngine' => 'Phobject', diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php index f85c79621c..68f87a6f6b 100644 --- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php +++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php @@ -516,7 +516,7 @@ final class ManiphestTaskSearchEngine ); if (ManiphestTaskPoints::getIsEnabled()) { - $fields[] = id(new PhabricatorIntExportField()) + $fields[] = id(new PhabricatorDoubleExportField()) ->setKey('points') ->setLabel('Points'); } diff --git a/src/infrastructure/export/field/PhabricatorDoubleExportField.php b/src/infrastructure/export/field/PhabricatorDoubleExportField.php new file mode 100644 index 0000000000..18087dd706 --- /dev/null +++ b/src/infrastructure/export/field/PhabricatorDoubleExportField.php @@ -0,0 +1,25 @@ +setDataType(PHPExcel_Cell_DataType::TYPE_NUMERIC); + } + + public function getCharacterWidth() { + return 8; + } + +} diff --git a/src/infrastructure/export/format/PhabricatorExcelExportFormat.php b/src/infrastructure/export/format/PhabricatorExcelExportFormat.php index 2b0c787884..606df393d0 100644 --- a/src/infrastructure/export/format/PhabricatorExcelExportFormat.php +++ b/src/infrastructure/export/format/PhabricatorExcelExportFormat.php @@ -155,8 +155,12 @@ EOHELP return $this->sheet; } + + /** + * @phutil-external-symbol class PHPExcel_Cell + */ private function getCellName($col, $row = null) { - $col_name = chr(ord('A') + $col); + $col_name = PHPExcel_Cell::stringFromColumnIndex($col); if ($row === null) { return $col_name;