How to get the Content Path from the Pyramid Repository in Usage Reporting
In the usage report that I built based on Transaction logs in Pyramid, I am not able to get the 'Path' for my dashboard or report objects. Is there a way to get a path field for the content?
1 reply
-
The information is stored in the Content_Tbl_Item table as a parent/child dimension. To get the full path, you have to write a recursive query. If your repository is using SQL Server as opposed to PostgreSQL, you can use the following query to get the full path:
WITH ContentQuery AS ( SELECT id, [name] as ItemName, folder_id, CAST('' AS NVARCHAR(MAX)) AS Breadcrumb FROM [dbo].[content_tbl_item] WHERE folder_id IS NULL UNION ALL SELECT ci.id, [name] as ItemName, ci.folder_id, cq.Breadcrumb + '/' + ci.[name] AS Breadcrumb FROM ContentQuery cq INNER JOIN [dbo].[content_tbl_item] ci ON cq.id = ci.folder_id ) SELECT id AS item_id, ItemName, folder_id, Breadcrumb FROM ContentQuery
Here is an example of what the query returns:
You will have to then join this information to any other data you are pulling from the repository. If you are using the Transaction View as your primary source for usage information, there is no Item ID field to join this path data to. The transactionView is designed to give you the most common/basic fields used in understanding usage. Any time you want to get more information, you will need to work with the raw tables. So you can feel free to update the view to add the Item_ID field or you can swap out the view in your model for a custom SQL query that uses the same initial logic as the view but adds the additional fields you want.
*NOTE: Pyramid does not recommend modifying the view directly as it could change in a subsequent versions which would overwrite your modifications. Proceed with caution!