Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Find a better way to determine last status change#4989

Merged
mitchell852 merged 10 commits intoapache:masterfrom
srijeet0406:status_last_change
Aug 31, 2020
Merged

Find a better way to determine last status change#4989
mitchell852 merged 10 commits intoapache:masterfrom
srijeet0406:status_last_change

Conversation

@srijeet0406
Copy link
Contributor

What does this PR (Pull Request) do?

Which Traffic Control components are affected by this PR?

  • CDN in a Box
  • Traffic Ops
  • Traffic Portal
  • CI tests

What is the best way to verify this PR?

Run local TO and TP and create a server. Notice that the status_last_updated field gets set to the current time in the DB.
Now, go to TP, and select the Status Last Updated as one of the display columns for the servers table. Notice that it shows the correct time elapsed since you created the server.
Now, update this server changing any field, EXCEPT the status of the server. Notice that the status_last_updated value DOES NOT change.
Now, update the server by changing the server's status (you will have to do this from the backend call, since TP doesn't let you do it from the front end).
Notice that the status_last_updated time gets changed to the current time this time around.

Also, make sure unit tests and API tests pass.

If this is a bug fix, what versions of Traffic Control are affected?

  • master

The following criteria are ALL met by this PR

  • This PR includes tests OR
  • This PR does not include documentation
  • This PR includes an update to CHANGELOG.md
  • This PR includes any and all required license headers
  • This PR ensures that database migration sequence is correct
  • This PR DOES NOT FIX A SERIOUS SECURITY VULNERABILITY (see the Apache Software Foundation's security guidelines for details)

Additional Information

@ocket8888 ocket8888 added cdn-in-a-box related to the Docker-based CDN-in-a-Box system new feature A new feature, capability or behavior Traffic Ops related to Traffic Ops Traffic Portal v1 related to Traffic Portal version 1 and removed cdn-in-a-box related to the Docker-based CDN-in-a-Box system labels Aug 26, 2020
@mitchell852 mitchell852 added the database relating to setup/installation/structure of the Traffic Ops database label Aug 28, 2020
@mitchell852
Copy link
Member

sorry, conflict in our favorite file :)

@srijeet0406
Copy link
Contributor Author

@mitchell852 fixed 👍

mitchell852 and others added 2 commits August 28, 2020 14:22
adds a read-only form field to the server form to display status last…
@mitchell852
Copy link
Member

for some reason the column filter is not working in TP on this field:

image

I have a server i just changed the status of and it's not showing up. So i'm wondering if the data format needs to be changed to that of LastUpdated:

lastUpdated: "2020-08-28 20:53:55+00",
statusLastUpdated: "2020-08-28T20:53:55.75928Z"

I'm not sure if that will solve the TP grid problem but maybe consistent is better anyhow?

@ocket8888
Copy link
Contributor

The data will compare properly if you coerce it to a Date. If you look in the servers table controller, when I set $scope.servers I map the returned servers array and apply a conversion to Date objects on the Last Updated field. So no, it's not that the Last Updated format works (in fact it's worse than the statusLastUpdated field, I had to do some string manipulation to get the Date constructor to work), it's just that it can only filter Dates by date.

@srijeet0406
Copy link
Contributor Author

Resolved in 97bca2f

@mitchell852
Copy link
Member

Can you update dateCellFormatter as well to this?

	/**
	 * Formats the contents of the 'lastUpdated' and 'statusLastUpdated' column cells as "relative to now".
	 */
	function dateCellFormatter(params) {
		return params.value ? dateUtils.getRelativeTime(params.value) : params.value;
	}

so dateUtils.getRelativeTime doesn't try to parse a null which displays "Invalid Date"

Copy link
Member

@mitchell852 mitchell852 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. all tests pass. verified manually as well. all requested changes have been made.

@mitchell852 mitchell852 merged commit 2c54c27 into apache:master Aug 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

database relating to setup/installation/structure of the Traffic Ops database new feature A new feature, capability or behavior Traffic Ops related to Traffic Ops Traffic Portal v1 related to Traffic Portal version 1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New TO server field: LastStatusChange

3 participants