As we've discussed, Lawrence wants to get CS subscription and time-spent data for all tickets including those which we started but were handed outside of CS's visibility (eg., to security). ST's code is quite different from RT's in this respect since this involves custom fields, so I installed RT on an ubuntu system and did a bunch of testing. For easier installing via ubuntu package, I did the below on RT 4.2 but I've confirmed the schema is identical for the columns we're interested in in 4.4. Here's my proposed plan: 1) a new database user "cs-rt" receives access to the following columns in RT's "Transactions" table: ObjectId, Created, ObjectType, TimeTaken 2) a new database view is created, visible to user "cs-rt", which returns key/value of ticket and subscription-code, for all RT queues. CREATE VIEW CsSubscriptions AS SELECT DISTINCT ObjectCustomFieldValues.ObjectId, ObjectCustomFieldValues.content as SubscriptionCode FROM ObjectCustomFieldValues INNER JOIN CustomFields ON ObjectCustomFieldValues.CustomField = CustomFields.id WHERE ObjectCustomFieldValues.ObjectType = "RT::Ticket" AND CustomFields.Disabled = 0 AND ObjectCustomFieldValues.Disabled = 0 AND CustomFields.Name = "CSSubscription" Then I believe my code just needs to run a query similar to: select Transactions.TimeTaken, CsSubscriptions.SubscriptionCode from Transactions, CsSubscriptions WHERE Transactions.ObjectType = 'RT::Ticket' AND Transactions.ObjectId = CsSubscriptions.ObjectId AND Transactions.Created > '2017-02-01 15:22:34' AND transactions.Created < '2017-01-01 00:00:00' Remarks: - I wrote this to be as security-restrictive as possible. - this is a fix for the first of two apps Lawrence runs (the subscriptions app). I haven't fully spec'd out the needs for the second app (ST-time-tracking) but it uses the above data, and also Transactions.Creator, some fields from Tickets table: (id, Queue, Status, Subject) that I want to test before I give you a suggested plan. But I wanted to let you know there would be another request later. (Hm, I guess it would also need Queues.Name and Queues.id - so maybe for simplicity that should also be a view).
-- DanielAllen - 2017-03-08