refactor "canonical" and "alias" path types into constants (CANONICAL_PATH_TYPE and ALIAS_PATH_TYPE respectively) to avoid repetition
return all the alias paths along with the canonical on updateCanonicalWithAlias - so we can keep composer up to date with the source of truth
add a lastModified property to all the alias path records - so we can sort them in composer (dynamodb does not retain insertion order)
in order to do the two above, I had to change theDynamo.pathsTable.updateItem call to have a 'return value' mode of ALL_NEW so we could get the item representing the 'new' alias record (so it can be returned with the 'new' canonical and any previous alias records).
PLUS it looks like the Stage of TeamCity has changed to something other than DEVINFRA and as such TC agent was attempting to connect to Dynamo in AWS (rather than the local one launched via DockerKit) - so changed this initialisation to rely on the App tag being path-manager (which we control and so less likely to break without us realising).
How to test (with postman or similar)
run path-manager locally (easiest way is sbt start)
Main risk would be performance, if this is used for articles which have a large amount of aliases, but I suggest we cross that bridge at the time if it actually causes problems.
What does this change?
"canonical"
and"alias"
path types into constants (CANONICAL_PATH_TYPE
andALIAS_PATH_TYPE
respectively) to avoid repetitionupdateCanonicalWithAlias
- so we can keep composer up to date with the source of truthlastModified
property to all the alias path records - so we can sort them in composer (dynamodb does not retain insertion order)Dynamo.pathsTable.updateItem
call to have a 'return value' mode ofALL_NEW
so we could get the item representing the 'new' alias record (so it can be returned with the 'new' canonical and any previous alias records).PLUS it looks like the
Stage
of TeamCity has changed to something other thanDEVINFRA
and as such TC agent was attempting to connect to Dynamo in AWS (rather than the local one launched via DockerKit) - so changed this initialisation to rely on theApp
tag beingpath-manager
(which we control and so less likely to break without us realising).How to test (with postman or similar)
path-manager
locally (easiest way issbt start
)POST
https://pathmanager.local.dev-gutools.co.uk/paths
Content-Type
:application/x-www-form-urlencoded
path
property set to something of your choice (e.g.pr/testing/1
)system
property set to something liketest
POST
https://pathmanager.local.dev-gutools.co.uk/paths/{ ID_FROM_STEP_2 }?shouldFormAlias=true
{ ID_FROM_STEP_2 }
replaced accordinglyContent-Type
:application/x-www-form-urlencoded
path
property set to something of your choice (e.g.pr/testing/2
, i.e different from step 2 )path
canonical
recordalias
recordsalias
record should have alastModified
propertyHow can we measure success?
This is a facilitates a composer PR which integrates the alias functionality in
path-manager
for use in the Evolving URLs project - https://github.com/guardian/flexible-content/pull/3620.Have we considered potential risks?
Main risk would be performance, if this is used for articles which have a large amount of aliases, but I suggest we cross that bridge at the time if it actually causes problems.