update assignee history
This commit is contained in:
		
							parent
							
								
									2123a1e9fb
								
							
						
					
					
						commit
						247abea9e7
					
				| 
						 | 
				
			
			@ -84,7 +84,16 @@ class JiraService
 | 
			
		|||
            '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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -58,6 +58,7 @@ interface Issue {
 | 
			
		|||
  self: string
 | 
			
		||||
  key: string
 | 
			
		||||
  fields: IssueFields
 | 
			
		||||
  changelog: Changelog
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface IssueFields {
 | 
			
		||||
| 
						 | 
				
			
			@ -118,6 +119,31 @@ interface UserWorklog {
 | 
			
		|||
    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 [loader, setLoader] = useState(true)
 | 
			
		||||
  const [updating, setUpdating] = useState(true)
 | 
			
		||||
| 
						 | 
				
			
			@ -156,11 +182,11 @@ const Worklogs = () => {
 | 
			
		|||
      }
 | 
			
		||||
 | 
			
		||||
      setUpdating(true)
 | 
			
		||||
    } catch (error:any) {
 | 
			
		||||
    } catch (error: any) {
 | 
			
		||||
      console.log(error)
 | 
			
		||||
      notifications.show({
 | 
			
		||||
        title: 'Error',
 | 
			
		||||
        message: error.message??error,
 | 
			
		||||
        message: error.message ?? error,
 | 
			
		||||
        color: 'red',
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -236,7 +262,6 @@ const Worklogs = () => {
 | 
			
		|||
              size="xs"
 | 
			
		||||
              label="To date:"
 | 
			
		||||
              value={new Date(date.endDate)}
 | 
			
		||||
              
 | 
			
		||||
              // clearable
 | 
			
		||||
              m={'0 10px'}
 | 
			
		||||
              w={'20%'}
 | 
			
		||||
| 
						 | 
				
			
			@ -426,7 +451,7 @@ const Worklogs = () => {
 | 
			
		|||
                                  <a
 | 
			
		||||
                                    href={`https://apactechvn.atlassian.net/browse/${iss.key}`}
 | 
			
		||||
                                    target="_blank"
 | 
			
		||||
                                    style={{textDecoration:"none"}}
 | 
			
		||||
                                    style={{ textDecoration: 'none' }}
 | 
			
		||||
                                  >
 | 
			
		||||
                                    [{iss.key}]{` ${iss.fields.summary}`}
 | 
			
		||||
                                  </a>
 | 
			
		||||
| 
						 | 
				
			
			@ -435,11 +460,15 @@ const Worklogs = () => {
 | 
			
		|||
                            </Text>
 | 
			
		||||
                            <Text fz={14}>
 | 
			
		||||
                              <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 fz={14}>
 | 
			
		||||
                              <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 fz={14}>
 | 
			
		||||
                              <b>
 | 
			
		||||
| 
						 | 
				
			
			@ -452,41 +481,47 @@ const Worklogs = () => {
 | 
			
		|||
                                  )
 | 
			
		||||
                                </span>
 | 
			
		||||
                                :
 | 
			
		||||
                              </b>{' '}<Badge color='green' size='sm' mb={'xs'}>
 | 
			
		||||
                              {iss.fields.worklog.worklogs?.reduce(
 | 
			
		||||
                                (accumulator, currentValue) => {
 | 
			
		||||
                                  if (
 | 
			
		||||
                                    parseInt(
 | 
			
		||||
                                      moment(date.startDate).format('YYYYMMDD'),
 | 
			
		||||
                                    ) <=
 | 
			
		||||
                              </b>{' '}
 | 
			
		||||
                              <Badge color="green" size="sm" mb={'xs'}>
 | 
			
		||||
                                {iss.fields.worklog.worklogs?.reduce(
 | 
			
		||||
                                  (accumulator, currentValue) => {
 | 
			
		||||
                                    if (
 | 
			
		||||
                                      parseInt(
 | 
			
		||||
                                        moment(date.startDate).format(
 | 
			
		||||
                                          'YYYYMMDD',
 | 
			
		||||
                                        ),
 | 
			
		||||
                                      ) <=
 | 
			
		||||
                                        parseInt(
 | 
			
		||||
                                          moment(currentValue.started).format(
 | 
			
		||||
                                            'YYYYMMDD',
 | 
			
		||||
                                          ),
 | 
			
		||||
                                        ) &&
 | 
			
		||||
                                      parseInt(
 | 
			
		||||
                                        moment(currentValue.started).format(
 | 
			
		||||
                                          'YYYYMMDD',
 | 
			
		||||
                                        ),
 | 
			
		||||
                                      ) &&
 | 
			
		||||
                                    parseInt(
 | 
			
		||||
                                      moment(currentValue.started).format(
 | 
			
		||||
                                        'YYYYMMDD',
 | 
			
		||||
                                      ),
 | 
			
		||||
                                    ) <=
 | 
			
		||||
                                      parseInt(
 | 
			
		||||
                                        moment(date.endDate).format('YYYYMMDD'),
 | 
			
		||||
                                      ) &&
 | 
			
		||||
                                    currentValue.updateAuthor.displayName ===
 | 
			
		||||
                                      user.username
 | 
			
		||||
                                  ) {
 | 
			
		||||
                                    return (
 | 
			
		||||
                                      accumulator +
 | 
			
		||||
                                      currentValue.timeSpentSeconds
 | 
			
		||||
                                    )
 | 
			
		||||
                                  }
 | 
			
		||||
                                  return accumulator
 | 
			
		||||
                                },
 | 
			
		||||
                                0,
 | 
			
		||||
                              ) /
 | 
			
		||||
                                60 /
 | 
			
		||||
                                60}
 | 
			
		||||
                              h</Badge>
 | 
			
		||||
                                      ) <=
 | 
			
		||||
                                        parseInt(
 | 
			
		||||
                                          moment(date.endDate).format(
 | 
			
		||||
                                            'YYYYMMDD',
 | 
			
		||||
                                          ),
 | 
			
		||||
                                        ) &&
 | 
			
		||||
                                      currentValue.updateAuthor.displayName ===
 | 
			
		||||
                                        user.username
 | 
			
		||||
                                    ) {
 | 
			
		||||
                                      return (
 | 
			
		||||
                                        accumulator +
 | 
			
		||||
                                        currentValue.timeSpentSeconds
 | 
			
		||||
                                      )
 | 
			
		||||
                                    }
 | 
			
		||||
                                    return accumulator
 | 
			
		||||
                                  },
 | 
			
		||||
                                  0,
 | 
			
		||||
                                ) /
 | 
			
		||||
                                  60 /
 | 
			
		||||
                                  60}
 | 
			
		||||
                                h
 | 
			
		||||
                              </Badge>
 | 
			
		||||
                            </Text>
 | 
			
		||||
                          </Box>
 | 
			
		||||
                          {iss.fields.worklog.worklogs?.map((log, index) => {
 | 
			
		||||
| 
						 | 
				
			
			@ -574,6 +609,7 @@ const Worklogs = () => {
 | 
			
		|||
                        >
 | 
			
		||||
                          <b>{iss.fields.status.name}</b>
 | 
			
		||||
                        </Text>
 | 
			
		||||
 | 
			
		||||
                        <Badge color="#6140c0e0">
 | 
			
		||||
                          <Box
 | 
			
		||||
                            display={'flex'}
 | 
			
		||||
| 
						 | 
				
			
			@ -598,7 +634,7 @@ const Worklogs = () => {
 | 
			
		|||
                              <a
 | 
			
		||||
                                href={`https://apactechvn.atlassian.net/browse/${iss.key}`}
 | 
			
		||||
                                target="_blank"
 | 
			
		||||
                                style={{textDecoration:"none"}}
 | 
			
		||||
                                style={{ textDecoration: 'none' }}
 | 
			
		||||
                              >
 | 
			
		||||
                                [{iss.key}]{` ${iss.fields.summary}`}
 | 
			
		||||
                              </a>
 | 
			
		||||
| 
						 | 
				
			
			@ -606,12 +642,29 @@ const Worklogs = () => {
 | 
			
		|||
                          </Tooltip>
 | 
			
		||||
                        </Text>
 | 
			
		||||
                        <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 fz={13}>
 | 
			
		||||
                          <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>
 | 
			
		||||
                        {/* 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>
 | 
			
		||||
                    )
 | 
			
		||||
                  })}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue