update assignee history
This commit is contained in:
		
							parent
							
								
									2123a1e9fb
								
							
						
					
					
						commit
						247abea9e7
					
				| 
						 | 
					@ -84,9 +84,18 @@ class JiraService
 | 
				
			||||||
            'body' => json_encode($body)
 | 
					            'body' => json_encode($body)
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return json_decode($response->getBody()->getContents(), true);
 | 
					        $issues = json_decode($response->getBody()->getContents(), true);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        foreach ($issues['issues'] as &$issue) {
 | 
				
			||||||
 | 
					            $issueKey = $issue['key'];
 | 
				
			||||||
 | 
					            $issueResponse = $this->client->get("/rest/api/3/issue/{$issueKey}?expand=changelog");
 | 
				
			||||||
 | 
					            $issueDetails = json_decode($issueResponse->getBody()->getContents(), true);
 | 
				
			||||||
 | 
					            $issue['changelog'] = $issueDetails['changelog'];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $issues;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    public function getAllUsers()
 | 
					    public function getAllUsers()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $response = $this->client->get('/rest/api/3/users/search', [
 | 
					        $response = $this->client->get('/rest/api/3/users/search', [
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,6 +58,7 @@ interface Issue {
 | 
				
			||||||
  self: string
 | 
					  self: string
 | 
				
			||||||
  key: string
 | 
					  key: string
 | 
				
			||||||
  fields: IssueFields
 | 
					  fields: IssueFields
 | 
				
			||||||
 | 
					  changelog: Changelog
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface IssueFields {
 | 
					interface IssueFields {
 | 
				
			||||||
| 
						 | 
					@ -118,6 +119,31 @@ interface UserWorklog {
 | 
				
			||||||
    issues: Issue[]
 | 
					    issues: Issue[]
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					interface Item {
 | 
				
			||||||
 | 
					  field: string
 | 
				
			||||||
 | 
					  fieldtype: string
 | 
				
			||||||
 | 
					  fieldId: string
 | 
				
			||||||
 | 
					  from: string | null
 | 
				
			||||||
 | 
					  fromString: string | null
 | 
				
			||||||
 | 
					  to: string | null
 | 
				
			||||||
 | 
					  toString: string | null
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					interface History {
 | 
				
			||||||
 | 
					  id: string
 | 
				
			||||||
 | 
					  author: UserInfo
 | 
				
			||||||
 | 
					  created: string
 | 
				
			||||||
 | 
					  items: Item[]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					interface Changelog {
 | 
				
			||||||
 | 
					  startAt: number
 | 
				
			||||||
 | 
					  maxResults: number
 | 
				
			||||||
 | 
					  total: number
 | 
				
			||||||
 | 
					  histories: History[]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const Worklogs = () => {
 | 
					const Worklogs = () => {
 | 
				
			||||||
  const [loader, setLoader] = useState(true)
 | 
					  const [loader, setLoader] = useState(true)
 | 
				
			||||||
  const [updating, setUpdating] = useState(true)
 | 
					  const [updating, setUpdating] = useState(true)
 | 
				
			||||||
| 
						 | 
					@ -156,11 +182,11 @@ const Worklogs = () => {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      setUpdating(true)
 | 
					      setUpdating(true)
 | 
				
			||||||
    } catch (error:any) {
 | 
					    } catch (error: any) {
 | 
				
			||||||
      console.log(error)
 | 
					      console.log(error)
 | 
				
			||||||
      notifications.show({
 | 
					      notifications.show({
 | 
				
			||||||
        title: 'Error',
 | 
					        title: 'Error',
 | 
				
			||||||
        message: error.message??error,
 | 
					        message: error.message ?? error,
 | 
				
			||||||
        color: 'red',
 | 
					        color: 'red',
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -236,7 +262,6 @@ const Worklogs = () => {
 | 
				
			||||||
              size="xs"
 | 
					              size="xs"
 | 
				
			||||||
              label="To date:"
 | 
					              label="To date:"
 | 
				
			||||||
              value={new Date(date.endDate)}
 | 
					              value={new Date(date.endDate)}
 | 
				
			||||||
              
 | 
					 | 
				
			||||||
              // clearable
 | 
					              // clearable
 | 
				
			||||||
              m={'0 10px'}
 | 
					              m={'0 10px'}
 | 
				
			||||||
              w={'20%'}
 | 
					              w={'20%'}
 | 
				
			||||||
| 
						 | 
					@ -426,7 +451,7 @@ const Worklogs = () => {
 | 
				
			||||||
                                  <a
 | 
					                                  <a
 | 
				
			||||||
                                    href={`https://apactechvn.atlassian.net/browse/${iss.key}`}
 | 
					                                    href={`https://apactechvn.atlassian.net/browse/${iss.key}`}
 | 
				
			||||||
                                    target="_blank"
 | 
					                                    target="_blank"
 | 
				
			||||||
                                    style={{textDecoration:"none"}}
 | 
					                                    style={{ textDecoration: 'none' }}
 | 
				
			||||||
                                  >
 | 
					                                  >
 | 
				
			||||||
                                    [{iss.key}]{` ${iss.fields.summary}`}
 | 
					                                    [{iss.key}]{` ${iss.fields.summary}`}
 | 
				
			||||||
                                  </a>
 | 
					                                  </a>
 | 
				
			||||||
| 
						 | 
					@ -435,11 +460,15 @@ const Worklogs = () => {
 | 
				
			||||||
                            </Text>
 | 
					                            </Text>
 | 
				
			||||||
                            <Text fz={14}>
 | 
					                            <Text fz={14}>
 | 
				
			||||||
                              <b>Estimate:</b>{' '}
 | 
					                              <b>Estimate:</b>{' '}
 | 
				
			||||||
                              <Badge color='red' size='sm'>{iss.fields.timeoriginalestimate / 60 / 60}h</Badge>
 | 
					                              <Badge color="red" size="sm">
 | 
				
			||||||
 | 
					                                {iss.fields.timeoriginalestimate / 60 / 60}h
 | 
				
			||||||
 | 
					                              </Badge>
 | 
				
			||||||
                            </Text>
 | 
					                            </Text>
 | 
				
			||||||
                            <Text fz={14}>
 | 
					                            <Text fz={14}>
 | 
				
			||||||
                              <b>Total time spent:</b>{' '}
 | 
					                              <b>Total time spent:</b>{' '}
 | 
				
			||||||
                              <Badge color='orange' size='sm'>{iss.fields.timespent / 60 / 60}h</Badge>
 | 
					                              <Badge color="orange" size="sm">
 | 
				
			||||||
 | 
					                                {iss.fields.timespent / 60 / 60}h
 | 
				
			||||||
 | 
					                              </Badge>
 | 
				
			||||||
                            </Text>
 | 
					                            </Text>
 | 
				
			||||||
                            <Text fz={14}>
 | 
					                            <Text fz={14}>
 | 
				
			||||||
                              <b>
 | 
					                              <b>
 | 
				
			||||||
| 
						 | 
					@ -452,41 +481,47 @@ const Worklogs = () => {
 | 
				
			||||||
                                  )
 | 
					                                  )
 | 
				
			||||||
                                </span>
 | 
					                                </span>
 | 
				
			||||||
                                :
 | 
					                                :
 | 
				
			||||||
                              </b>{' '}<Badge color='green' size='sm' mb={'xs'}>
 | 
					                              </b>{' '}
 | 
				
			||||||
                              {iss.fields.worklog.worklogs?.reduce(
 | 
					                              <Badge color="green" size="sm" mb={'xs'}>
 | 
				
			||||||
                                (accumulator, currentValue) => {
 | 
					                                {iss.fields.worklog.worklogs?.reduce(
 | 
				
			||||||
                                  if (
 | 
					                                  (accumulator, currentValue) => {
 | 
				
			||||||
                                    parseInt(
 | 
					                                    if (
 | 
				
			||||||
                                      moment(date.startDate).format('YYYYMMDD'),
 | 
					                                      parseInt(
 | 
				
			||||||
                                    ) <=
 | 
					                                        moment(date.startDate).format(
 | 
				
			||||||
 | 
					                                          'YYYYMMDD',
 | 
				
			||||||
 | 
					                                        ),
 | 
				
			||||||
 | 
					                                      ) <=
 | 
				
			||||||
 | 
					                                        parseInt(
 | 
				
			||||||
 | 
					                                          moment(currentValue.started).format(
 | 
				
			||||||
 | 
					                                            'YYYYMMDD',
 | 
				
			||||||
 | 
					                                          ),
 | 
				
			||||||
 | 
					                                        ) &&
 | 
				
			||||||
                                      parseInt(
 | 
					                                      parseInt(
 | 
				
			||||||
                                        moment(currentValue.started).format(
 | 
					                                        moment(currentValue.started).format(
 | 
				
			||||||
                                          'YYYYMMDD',
 | 
					                                          'YYYYMMDD',
 | 
				
			||||||
                                        ),
 | 
					                                        ),
 | 
				
			||||||
                                      ) &&
 | 
					                                      ) <=
 | 
				
			||||||
                                    parseInt(
 | 
					                                        parseInt(
 | 
				
			||||||
                                      moment(currentValue.started).format(
 | 
					                                          moment(date.endDate).format(
 | 
				
			||||||
                                        'YYYYMMDD',
 | 
					                                            'YYYYMMDD',
 | 
				
			||||||
                                      ),
 | 
					                                          ),
 | 
				
			||||||
                                    ) <=
 | 
					                                        ) &&
 | 
				
			||||||
                                      parseInt(
 | 
					                                      currentValue.updateAuthor.displayName ===
 | 
				
			||||||
                                        moment(date.endDate).format('YYYYMMDD'),
 | 
					                                        user.username
 | 
				
			||||||
                                      ) &&
 | 
					                                    ) {
 | 
				
			||||||
                                    currentValue.updateAuthor.displayName ===
 | 
					                                      return (
 | 
				
			||||||
                                      user.username
 | 
					                                        accumulator +
 | 
				
			||||||
                                  ) {
 | 
					                                        currentValue.timeSpentSeconds
 | 
				
			||||||
                                    return (
 | 
					                                      )
 | 
				
			||||||
                                      accumulator +
 | 
					                                    }
 | 
				
			||||||
                                      currentValue.timeSpentSeconds
 | 
					                                    return accumulator
 | 
				
			||||||
                                    )
 | 
					                                  },
 | 
				
			||||||
                                  }
 | 
					                                  0,
 | 
				
			||||||
                                  return accumulator
 | 
					                                ) /
 | 
				
			||||||
                                },
 | 
					                                  60 /
 | 
				
			||||||
                                0,
 | 
					                                  60}
 | 
				
			||||||
                              ) /
 | 
					                                h
 | 
				
			||||||
                                60 /
 | 
					                              </Badge>
 | 
				
			||||||
                                60}
 | 
					 | 
				
			||||||
                              h</Badge>
 | 
					 | 
				
			||||||
                            </Text>
 | 
					                            </Text>
 | 
				
			||||||
                          </Box>
 | 
					                          </Box>
 | 
				
			||||||
                          {iss.fields.worklog.worklogs?.map((log, index) => {
 | 
					                          {iss.fields.worklog.worklogs?.map((log, index) => {
 | 
				
			||||||
| 
						 | 
					@ -574,6 +609,7 @@ const Worklogs = () => {
 | 
				
			||||||
                        >
 | 
					                        >
 | 
				
			||||||
                          <b>{iss.fields.status.name}</b>
 | 
					                          <b>{iss.fields.status.name}</b>
 | 
				
			||||||
                        </Text>
 | 
					                        </Text>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        <Badge color="#6140c0e0">
 | 
					                        <Badge color="#6140c0e0">
 | 
				
			||||||
                          <Box
 | 
					                          <Box
 | 
				
			||||||
                            display={'flex'}
 | 
					                            display={'flex'}
 | 
				
			||||||
| 
						 | 
					@ -598,7 +634,7 @@ const Worklogs = () => {
 | 
				
			||||||
                              <a
 | 
					                              <a
 | 
				
			||||||
                                href={`https://apactechvn.atlassian.net/browse/${iss.key}`}
 | 
					                                href={`https://apactechvn.atlassian.net/browse/${iss.key}`}
 | 
				
			||||||
                                target="_blank"
 | 
					                                target="_blank"
 | 
				
			||||||
                                style={{textDecoration:"none"}}
 | 
					                                style={{ textDecoration: 'none' }}
 | 
				
			||||||
                              >
 | 
					                              >
 | 
				
			||||||
                                [{iss.key}]{` ${iss.fields.summary}`}
 | 
					                                [{iss.key}]{` ${iss.fields.summary}`}
 | 
				
			||||||
                              </a>
 | 
					                              </a>
 | 
				
			||||||
| 
						 | 
					@ -606,12 +642,29 @@ const Worklogs = () => {
 | 
				
			||||||
                          </Tooltip>
 | 
					                          </Tooltip>
 | 
				
			||||||
                        </Text>
 | 
					                        </Text>
 | 
				
			||||||
                        <Text fz={13}>
 | 
					                        <Text fz={13}>
 | 
				
			||||||
                          <b>Time spent:</b> <Badge color='orange' size='sm'>{iss.fields.timespent / 60 / 60}h</Badge>
 | 
					                          <b>Time spent:</b>{' '}
 | 
				
			||||||
 | 
					                          <Badge color="orange" size="sm">
 | 
				
			||||||
 | 
					                            {iss.fields.timespent / 60 / 60}h
 | 
				
			||||||
 | 
					                          </Badge>
 | 
				
			||||||
                        </Text>
 | 
					                        </Text>
 | 
				
			||||||
                        <Text fz={13}>
 | 
					                        <Text fz={13}>
 | 
				
			||||||
                          <b>Estimate:</b>{' '}
 | 
					                          <b>Estimate:</b>{' '}
 | 
				
			||||||
                          <Badge color='red' size='sm'>{iss.fields.timeoriginalestimate / 60 / 60}h</Badge>
 | 
					                          <Badge color="red" size="sm">
 | 
				
			||||||
 | 
					                            {iss.fields.timeoriginalestimate / 60 / 60}h
 | 
				
			||||||
 | 
					                          </Badge>
 | 
				
			||||||
                        </Text>
 | 
					                        </Text>
 | 
				
			||||||
 | 
					                        {/* History issue */}
 | 
				
			||||||
 | 
					                        {iss.changelog.histories.map((h) => {
 | 
				
			||||||
 | 
					                          return h.items.find((i) => i.field === 'assignee') ? (
 | 
				
			||||||
 | 
					                            <Text fz={13} fw={600}>{'Assigned at: ' + moment(h.created).format("HH:mm:ss DD/MM/YYYY")}</Text>
 | 
				
			||||||
 | 
					                          ) : h.items.find((i) => i.field === 'status')? (
 | 
				
			||||||
 | 
					                            <Text fz={13} fw={600}>{h.items.find((i) => i.field === 'status')
 | 
				
			||||||
 | 
					                            ?.fromString+" ➯ "+h.items.find((i) => i.field === 'status')
 | 
				
			||||||
 | 
					                            ?.toString +": "+ moment(h.created).format("HH:mm:ss DD/MM/YYYY")}</Text>
 | 
				
			||||||
 | 
					                          ) : (
 | 
				
			||||||
 | 
					                            ''
 | 
				
			||||||
 | 
					                          )
 | 
				
			||||||
 | 
					                        })}
 | 
				
			||||||
                      </Box>
 | 
					                      </Box>
 | 
				
			||||||
                    )
 | 
					                    )
 | 
				
			||||||
                  })}
 | 
					                  })}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue