Typo3, Typoscript. Output timestamp of last published workspace - typo3

I set up a TYPO3 6.2 with workspaces. All the content is changed in a staging workspace and published all together.
Now I want a label like "last changes: " on every page.
I don't want the date the page was changed, but the date the workspace edits were last published.
I got something like:
30 = CONTENT
30 {
table = sys_log
select {
selectFields = tstamp
where = (workspace = 1 AND tablename = 'tt_content' AND details_nr = 30 AND details = 'Published')
orderBy = tstamp DESC
max = 1
}
renderObj {
10 = TEXT
10.stdWrap.field = tstamp
10.stdWrap.wrap = (|)
}
wrap = <span class="tstamp">|</span>
}
I'm pretty much stuck here. There is no content rendered in frontend. I get the span, but the parentheses and their content is missing.
I tried to find examples, because the documentation is not that newbe-friendly written.
Thanks in advance.

The value you're looking for is stored in every workspace-aware table in the field t3ver_tstamp as unix timestamp. This field is updated only if data is published or "swapped", which is a special publish process.
Unfortunately the approach which selecting from the sys_log table won't work, since the relevant payload is PHP-serialized in the field log_data like e.g. a:2:{i:0;s:4:"Test";i:1;s:7:"pages:1";} (pointing to table pages with uid 1 in this example).
As far as I understood it, you want to retrieve the last point in time any record on a particular page has been published from a draft workspace to the live workspace - which means to select the maximum unix timestamp on any record for any table pointing to that particular page. Unfortunately this does not work with plain TypoScript, thus you have to implement a service implemented in PHP.
Given that you want to show the last publishing date for page with ID 123 that would require the following tasks:
SELECT t3ver_tstamp FROM pages WHERE uid=123...
foreach (array_keys($GLOBALS['TCA']) as $tableName)
SELECT MAX(t3ver_tstamp) FROM $tableName WHERE pid=123 AND t3ver_wsid=0...
determine maximum timestamp in PHP from the above

Related

How can I show InfluxDb tags only for todays date?

I am having trouble getting this query in InfluxDb to work properly. Wondering if someone can help.
I want to show tag values but only for the current days data. I have this
SHOW TAG VALUES FROM table WITH KEY = "name"
This list shows all values from the full measurement. I want to only show values for data that was inserted today.
I've tried
SHOW TAG VALUES FROM table WITH KEY = "name" where date='2018-10-23'
SHOW TAG VALUES FROM table WITH KEY = "name" where time='2018-10-23'
as well as some other variations but can't seem to get this right.
Does anyone know how to properly form this query?
I am using this as a variable inside Grafana.
Thanks
For select time you mast define time range, start and end.
This is working solution.
SHOW TAG VALUES FROM table WITH KEY = "name" where time>='2020-04-26T00:00:00Z' AND time<'2020-04-27T00:00:00Z'
Time condition is not supported in SHOW TAG VALUES query - there is an issue for that https://github.com/influxdata/influxdb/issues/5668. You can find a workaround with a continuous query in that issue comments.
how about use subquery? instead of "show tag values"
like this
# show tag values from with key = “TAGName” where condition
select TagName from (select field, TagName from Measurement where condition)
it return timestamp with tag values
Can't upvote answer https://stackoverflow.com/a/58404465/18224224 but this solution has worked for me.
select "tag_name" from (select "field_value", "tag_name" from "table" WHERE "tag_name_filter" = 'tag_value_filter' AND $timeFilter group by "tag_name" LIMIT 1)
$timefilter variable will automatically use dashboard time range selected if variable uses refresh : on time range change
Grafana Dashboard variables screenshot
Grafana Dashboard variables screenshot with different time range selected in dashboard

Preserve the records without value for measure in report

Aim: User wants to see all Auto's irrespective of Premium.
I created a tabular model for Auto Policies. Where an DimAuto is associated with FactPremium. However, there are cases in which an AutoItem Doesn't have a premium associated with it(the key for such AutoItems in FactPremium is 0 so that it can join to dimAuto). When browsing on excel I am not able to see the AutoItems that doesnt have premium associated with it in the Pivot Table.
I would like to know if there is any way to display every auto Items ?
In Excel, you can set this property in the PivotTable settings (Rows > Field Settings):
In PowerBI, this option is also available:
As alternative, you can adjust the measure, by adding 0 (zero)...
Sales plus 0 = SUM(Sales[Sales]) + 0
...or correct for blank values:
Sales if blank =
VAR Amount = SUM(Sales[Sales])
RETURN
IF (ISBLANK(Amount);0;Amount)

How to pull github timeline data from BigQuery

I am having trouble accessing the GitHub timeline from BigQuery.
I was using the following query:
SELECT repository_name, actor_attributes_company, payload_ref_type, payload_action, type, created_at FROM githubarchive:github.timeline WHERE repository_organization = 'foo' and created_at > '2014-07-01'
and everything was working great. Now, it looks like the githubarchive:github.timeline table is no longer available. I've been looking around and I found another table:
SELECT repository_name, actor_attributes_company, payload_ref_type, payload_action, type, created_at FROM publicdata:samples.github_timeline WHERE repository_organization = 'foo' and created_at > '2014-07-01'
This query works but returns zero rows. When I remove the created_at restriction it worked but only returned a few rows from 2012 so it looks like this is just sample data.
Does anyone know how to pull live timeline data from GitHub?
Indeed, publicdata:samples.github_timeline has only sample data.
For the real GitHub Archive documentation, look at http://www.githubarchive.org/
I wrote an article yesterday about querying it:
https://medium.com/#hoffa/analyzing-github-issues-and-comments-with-bigquery-c41410d3308
Sample query:
SELECT repo.name,
JSON_EXTRACT_SCALAR(payload, '$.action') action,
COUNT(*) c,
FROM [githubarchive:month.201606]
WHERE type IN ('IssuesEvent')
AND repo.name IN ('kubernetes/kubernetes', 'docker/docker', 'tensorflow/tensorflow')
GROUP BY 1,2
ORDER BY 2 DESC
As Mikhail points out, there's also another dataset with all of GitHub's code:
https://medium.com/#hoffa/github-on-bigquery-analyze-all-the-code-b3576fd2b150
Check out githubarchive BigQuery project
It has three datasets: day, month, year with respective daily, monthly and yearly data
Check out https://cloudplatform.googleblog.com/2016/06/GitHub-on-BigQuery-analyze-all-the-open-source-code.html for more details

Sort Parameter for 7 different fields in CR 10

I am attempting to write a sort field parameter for all of my 7 fields in CR10. I have followed the directions in the help section - Define sort order using parameter fields - and just tried 3 fields for the moment. I can't get either to work properly and I'm not sure if this is at all possible.
Here is what I have.
My report originally was grouped by 1 Payer ID and then 2 Claim Number. I removed those groups and moved my fields into the details section. Here are the fields:
`Claim#
Payer ID
Payer Name
Account#
Name
Billed Amt
Date`
I created a parameter called Sort Field, selected string and made sure my min and max were set to one. Placed the following into the prompting text:
`C = Claim
I = Payer ID
P = Payer Name
A = Account#
N = Name
B = Billed Amt
Date is Default`
I created a formula and called it Sort. I have tried this as stated above with all 7 fields and also only 3 fields - my main focus is all of the fields.
`If {?SortField} = "C"
Then totext({table.ClaimNumber},"########")
ElseIf {?SortField} = "I"
Then totext({table.ID_Payer},"########")
ElseIf {?SortField} = "P"
Then {table.PayerName}
ElseIf {?SortField} = "A"
Then totext({table.Account},"#######")
ElseIf {?SortField} = "N"
Then {table.Last_Name}
ElseIf {?SortField} = "B"
Then totext({table.ClaimGrossCharge},"#########.##")
Else totext({table.SubmittedDate},"")`
I then placed #Sort into the report header and suppressed in the section expert. I also included the following formula in the Record Selection:
`{table.SubmittedDate} >= {?Submitted Date From} and
{table.SubmittedDate} <= {?Submitted Date To} and
{#Sort} = {?SortField}`
Finally, I made sure that the #Sort formula was selected in the record sort expert.
I run the report and get nothing. I comment out {#Sort} = {?SortField} in the Record Selection and I get data. Although, the data is duplicating since it is not grouped as it was originally.
Can this be done? This option would be amazing for our clients and I have a feeling it can work but I believe I am missing something. Is my #Sort formula correct or does it need to be adjusted? I am attempting to make sure all of the fields are to text since I selected string in the parameter.
Any assistance would be greatly appreciated! Thank you for your time.
Its a bit lenghty question but will try to answer to the extent I understand.
I am assuming sort(From formula that you have written) you mean display only those values that client has selected and supress the rest and my answer will support this idea. If this is not you are looking for let me know will try to answer to the extent possible.
You shouldn't be using the {#Sort} = {?SortField} in record selection formula since this will be directly fired in database and as per your design this won't return any data as you parameter values doesn't match with the data in database.So remove this part from record selection.
Do place your sort formula in report header as it doesn't fetch full data in header and its of no use to supress.
As you place all fields in detail section you can use your created Sort formula in detail section in place of original fields which will do the job as per the user selection.
If you are getting the duplicate data then you need to check links to the tables or check the option Select Distinct Data in database tab which will remove duplicate data

Querying old links from public Facebook page returns an empty set

I am trying to fetch links that were posted on a public Facebook page sometime ago, in 2011 for example. Specifically, the Arabic CNN page on facebook: http://www.facebook.com/CNNArabic
Things I tried:
1- Graph API, a query like this:
CNNArabic/links?fields=id,name,link,created_time&limit=25&until=2012-05-15
2- FQL
SELECT link_id, url, created_time FROM link WHERE owner = 102581028206 and created_time < 1337085958 LIMIT 100
Both give an empty data set while there is data on the page on or before this date.
Other things I noticed:
1-If I changed the date to something like 2013-01-17 (which is yesterday), it works fine.
2-If I changed the date to something like 2012-12-17 (about a month ago), an empty data set is returned, however if I followed the next page links in the returned data set from the query in number 1 above until I pass by this date I actually get data.
I tried writing code that kept following the next page pointers until I reach the links on the date I want. However I need data much older (say in 2011) and the result set gets exhausted say 2 or 3 months earlier than now, in other words no more next links are returned so I actually can never reach that old data.
To cut this short:
is there a way I can query links that were posted on a public page before a specified date?
Querying the page's feed works in the Graph API:
/102581028206/feed?fields=id,link,name,created_time&limit=25&until=2012-05-15
This returns all the posts. There should be a way to filter this using field expansion, but I couldn't get the few things I tried to work.
You can get this filtered for links only with FQL on the stream table:
SELECT message, attachment, created_time FROM stream WHERE source_id = 102581028206
AND created_time < strtotime('2012-05-15') AND type=80 LIMIT 10
Links are type=80.