@@ -157,101 +157,19 @@ func CmdPRs(_ *cobra.Command, _ []string) error {
157
157
byStatus [statusText ] = append (byStatus [statusText ], pr .GetNumber ())
158
158
159
159
c .Printf (" open %d days, waiting %d days\n " , daysOpen , daysWaiting )
160
-
161
- // TODO switch to gh.UpdateItem
162
- q := `query=
163
- mutation (
164
- $project:ID!, $item:ID!,
165
- $status_field:ID!, $status_value:String!,
166
- $pr_field:ID!, $pr_value:String!,
167
- $user_field:ID!, $user_value:String!,
168
- $daysOpen_field:ID!, $daysOpen_value:Float!,
169
- $daysWait_field:ID!, $daysWait_value:Float!,
170
- ) {
171
- set_status: updateProjectV2ItemFieldValue(input: {
172
- projectId: $project
173
- itemId: $item
174
- fieldId: $status_field
175
- value: {
176
- singleSelectOptionId: $status_value
177
- }
178
- }) {
179
- projectV2Item {
180
- id
181
- }
182
- }
183
- set_pr: updateProjectV2ItemFieldValue(input: {
184
- projectId: $project
185
- itemId: $item
186
- fieldId: $pr_field
187
- value: {
188
- text: $pr_value
189
- }
190
- }) {
191
- projectV2Item {
192
- id
193
- }
194
- }
195
- set_user: updateProjectV2ItemFieldValue(input: {
196
- projectId: $project
197
- itemId: $item
198
- fieldId: $user_field
199
- value: {
200
- text: $user_value
201
- }
202
- }) {
203
- projectV2Item {
204
- id
205
- }
206
- }
207
- set_dopen: updateProjectV2ItemFieldValue(input: {
208
- projectId: $project
209
- itemId: $item
210
- fieldId: $daysOpen_field
211
- value: {
212
- number: $daysOpen_value
213
- }
214
- }) {
215
- projectV2Item {
216
- id
217
- }
218
- }
219
- set_dwait: updateProjectV2ItemFieldValue(input: {
220
- projectId: $project
221
- itemId: $item
222
- fieldId: $daysWait_field
223
- value: {
224
- number: $daysWait_value
225
- }
226
- }) {
227
- projectV2Item {
228
- id
229
- }
230
- }
231
- }
232
- `
233
-
234
- p := [][]string {
235
- {"-f" , "project=" + p .ID },
236
- {"-f" , "item=" + * iid },
237
- {"-f" , "status_field=" + p .FieldIDs ["Status" ]},
238
- {"-f" , "status_value=" + status },
239
- {"-f" , "pr_field=" + p .FieldIDs ["PR#" ]},
240
- {"-f" , fmt .Sprintf ("pr_value=%d" , * pr .Number )}, // todo string + value
241
- {"-f" , "user_field=" + p .FieldIDs ["User" ]},
242
- {"-f" , fmt .Sprintf ("user_value=%s" , pr .User .GetLogin ())},
243
- {"-f" , "daysOpen_field=" + p .FieldIDs ["Open Days" ]},
244
- {"-F" , fmt .Sprintf ("daysOpen_value=%d" , daysOpen )},
245
- {"-f" , "daysWait_field=" + p .FieldIDs ["Waiting Days" ]},
246
- {"-F" , fmt .Sprintf ("daysWait_value=%d" , daysWaiting )},
160
+
161
+ fields := []gh.ProjectItemField {
162
+ {Name : "number" , FieldID : p .FieldIDs ["#" ], Type : gh .ItemValueTypeNumber , Value : * pr .Number },
163
+ {Name : "status" , FieldID : p .FieldIDs ["Status" ], Type : gh .ItemValueTypeSingleSelect , Value : status },
164
+ {Name : "user" , FieldID : p .FieldIDs ["User" ], Type : gh .ItemValueTypeText , Value : pr .User .GetLogin ()},
165
+ {Name : "daysOpen" , FieldID : p .FieldIDs ["Open Days" ], Type : gh .ItemValueTypeNumber , Value : daysOpen },
166
+ {Name : "daysWait" , FieldID : p .FieldIDs ["Waiting Days" ], Type : gh .ItemValueTypeNumber , Value : daysWaiting },
247
167
}
248
168
249
- if ! f .DryRun {
250
- out , err := r .GraphQLQuery (q , p )
251
- if err != nil {
252
- c .Printf ("\n \n <red>ERROR!!</> %s\n %s" , err , * out )
253
- return nil
254
- }
169
+ err = p .UpdateItem (* iid , fields )
170
+ if err != nil {
171
+ c .Printf ("\n \n <red>ERROR!!</> %s" , err )
172
+ continue
255
173
}
256
174
257
175
c .Printf ("\n " )
0 commit comments