Skip to content

Commit 028cdcd

Browse files
committed
Merge branch 'filter-archived-versions'
2 parents e7a9a44 + 7cc4913 commit 028cdcd

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

dist/appsscript.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"timeZone": "America/New_York",
2+
"timeZone": "Asia/Tokyo",
33
"dependencies": {
44
},
55
"exceptionLogging": "STACKDRIVER"

src/BacklogClient.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ describe("BacklogClient", function () {
119119
"archived": false,
120120
"displayOrder": 0
121121
},
122+
{
123+
"id": 121209,
124+
"projectId": 12345,
125+
"name": "0.1.0",
126+
"description": null,
127+
"startDate": null,
128+
"releaseDueDate": null,
129+
"archived": true,
130+
"displayOrder": 2
131+
},
122132
{
123133
"id": 121213,
124134
"projectId": 12345,
@@ -127,7 +137,7 @@ describe("BacklogClient", function () {
127137
"startDate": null,
128138
"releaseDueDate": null,
129139
"archived": false,
130-
"displayOrder": 1
140+
"displayOrder": 3
131141
}]`
132142
}
133143

src/BacklogClient.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ export class BacklogClientImpl implements BacklogClient {
197197

198198
public getVersionsV2(id: Id<Project>): Version[] {
199199
const json = this.http.get(this.buildUri(`projects/${id}/versions`))
200-
return Object.keys(json).map(key => this.jsonTo(json[key]))
200+
return Object.keys(json)
201+
.filter(key => !json[key]["archived"])
202+
.map(key => this.jsonTo(json[key]))
201203
}
202204

203205
public getPrioritiesV2(): Priority[] {

src/BacklogService.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ const ROW_HEADER_INDEX = 1
1313
const COLUMN_START_INDEX = 1 /** データ列の開始インデックス */
1414
const ROW_START_INDEX = 2 /** データ行の開始インデックス */
1515
const DEFAULT_COLUMN_LENGTH = 16
16+
const MAX_LIST_ITEM_COUNT = 500
1617

1718
type Validation<A> = (a: A, onError: Error) => Either<Error, A>
1819

1920
const isEmpty: Validation<string> = (str: string, onError: Error): Either<Error, string> =>
2021
str !== "" ? Right(str) : Left(onError)
2122

23+
const slice = <A>(items: A[]): A[] =>
24+
items.slice(0, MAX_LIST_ITEM_COUNT - 1)
25+
2226
const createBacklogClient = (space: string, domain: string, apiKey: string, locale: Locale): Either<Error, BacklogClient> => {
2327
const spaceResult = isEmpty(space, Error(Message.SPACE_URL_REQUIRED(locale)))
2428
const apiKeyResult = isEmpty(apiKey, Error(Message.API_KEY_REQUIRED(locale)))
@@ -289,16 +293,16 @@ export const BacklogService = (spreadSheetService: SpreadSheetService): BacklogS
289293
showMessage(Message.PROGRESS_INIT_BEGIN(locale), spreadSheetService)
290294
return createBacklogClient(property.space, property.domain, property.apiKey, locale)
291295
.flatMap(client =>
292-
getProject(client, property.projectKey, locale).map(project =>
293-
BacklogDefinition(
294-
client.getIssueTypesV2(project.id),
295-
client.getCategoriesV2(project.id),
296-
client.getVersionsV2(project.id),
297-
client.getPrioritiesV2(),
298-
client.getUsersV2(project.id),
299-
client.getCustomFieldsV2(project.id)
300-
)
301-
)
296+
getProject(client, property.projectKey, locale).map(project => {
297+
const issueTypes = client.getIssueTypesV2(project.id)
298+
const categories = client.getCategoriesV2(project.id)
299+
const versions = client.getVersionsV2(project.id)
300+
const priorities = client.getPrioritiesV2()
301+
const users = client.getUsersV2(project.id)
302+
const customFields = client.getCustomFieldsV2(project.id)
303+
304+
return BacklogDefinition(slice(issueTypes), slice(categories), slice(versions), slice(priorities), slice(users), customFields)
305+
})
302306
)
303307
.map(definition => {
304308
const issueTypeRule = SpreadsheetApp.newDataValidation().requireValueInList(definition.issueTypeNames(), true).build()

0 commit comments

Comments
 (0)