Skip to content

Commit 63307ce

Browse files
committed
userIdは文字列、idは数字。APIは整数のuser.idを使うのでidを使う。
1 parent f5e224f commit 63307ce

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/lib/Backup/BacklogArchiver.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function storable ( BaseModel $obj ): array {
3636
return $arr;
3737
}
3838

39-
protected function filterAttrUser ( $arr, $class ) {
39+
protected function filterUserAttrs ( $arr, $class ) {
4040
$map = $class::attribute_mapping_list();
4141
$userAttrNames = array_map( fn( $e ) => $e[0], array_filter( $map, fn( $e ) => str_ends_with( $e[1], 'User' ) ) );
4242
$userArrayAttrNames = array_filter( $userAttrNames, fn( $str ) => $str == StrTool::plural( $str ) );
@@ -46,10 +46,10 @@ protected function filterAttrUser ( $arr, $class ) {
4646
$arr[$k] = $v['nulabId'] ?? null;
4747
}
4848
if ( in_array( $k, $userArrayAttrNames ) ) {
49-
$arr[$k] = array_map( fn( $e ) => $e["userId"], $v );
49+
$arr[$k] = array_map( fn( $e ) => $e["id"], $v );
5050
}
5151
if ( in_array( $k, $userAttrNames ) ) {
52-
$arr[$k] = $v["userId"] ?? null;
52+
$arr[$k] = $v["id"] ?? null;
5353
}
5454
}
5555

@@ -69,7 +69,7 @@ protected function filterAttribnutes($arr,$class,$attrName){
6969
return $arr;
7070
}
7171
protected function filterAttr( $arr, $class ) {
72-
$arr = $this->filterAttrUser($arr, $class);
72+
$arr = $this->filterUserAttrs($arr, $class);
7373
$arr = $this->filterAttribnutes($arr,$class, 'attachments');
7474
$arr = $this->filterAttribnutes($arr,$class, 'stars');
7575
$arr = $this->filterAttribnutes($arr,$class, 'sharedFiles');
@@ -124,7 +124,7 @@ protected function getInterfaceAttrs( $obj ) {
124124
if( $this->hasInterface($obj, ProjectAttrs::class) ) {
125125
/** @var ProjectAttrs $obj */
126126
$cols['teams'] = array_map(fn( $e ) => $e->id, $obj->teams());
127-
$cols['users'] = array_map(fn( $e ) => $e->userId, $obj->users());
127+
$cols['users'] = array_map(fn( $e ) => $e->id, $obj->users());
128128
}
129129

130130
return $cols;

tests/Unit/Backup/Storable/IssueStorableTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ protected function assert_issue_is_storable($arr){
2525
$this->assertIsArrayOfInt($arr['category']);
2626
$this->assertIsInt($arr['issueType']);
2727
$this->assertIsInt($arr['status']);
28-
$this->assertIsString($arr['createdUser']);
29-
$this->assertIsString($arr['assignee']);
30-
28+
$this->assertIsInt($arr['createdUser']);
29+
$this->assertIsInt($arr['assignee']);
3130
}
3231

3332
public function test_issue_storable(): void {

tests/Unit/Backup/Storable/ProjectStorableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function assert_project_is_storable ( $arr ) {
1717
$names = array_merge( $names, ['icon', 'users', 'teams', 'spaceKey'] );
1818
//
1919
$this->assertArrayIsSameValues( $names, array_keys( $arr ) );
20-
$this->assertIsArrayOfString( $arr['users'] );
20+
$this->assertIsArrayOfInt( $arr['users'] );
2121
$this->assertNotEmpty( $arr['users'] );
2222
$this->assertIsArray( $arr['teams'] );
2323
$this->assertIsArrayOfInt( $arr['teams'] );

0 commit comments

Comments
 (0)