This function suppose to show in which hours adverts are clicked more often.
It works fine however I have problem with sorting it by "HourOfDay". When I add ORDER BY HourOfDay to the end of the query I get en error.
function exportReportToSpreadsheet() {
var spreadsheet = SpreadsheetApp.create('INSERT_REPORT_NAME_HERE');
var report = AdWordsApp.report("SELECT Clicks, Impressions, AverageCpc, HourOfDay FROM ACCOUNT_PERFORMANCE_REPORT DURING LAST_MONTH ORDER BY HourOfDay");
report.exportToSheet(spreadsheet.getActiveSheet());
Logger.log("Report available at " + spreadsheet.getUrl());
}
exportReportToSpreadsheet();
Anyone knows what is wrong with ORDER BY in AdWordsApp.report ?
https://developers.google.com/adwords/scripts/docs/reference/adwordsapp/adwordsapp_report
According to AWQL query language documentation it should work as expected.
https://developers.google.com/adwords/api/docs/guides/awql#using_awql_with_reports
BUG?
You cannot sort reports. From the AWQL documentation:
ORDER BY and LIMIT (sorting and paging) are NOT supported for reports.
Including these clauses in a query will generate an error.
Ordering is only possible when you use the different entities` selectors, e.g. to iterate over campaigns sorted by cost you could do
campaignIterator = AdWordsApp
.campaigns()
.forDateRange("LAST_MONTH")
.orderBy("Clicks DESC");
Related
I am trying to receive email messages via Microsoft Graph API:
requestBuilder
.Delta()
.Request()
.Expand("attachments")
.GetAsync(ChildCancellationToken.Token);
but messages come in descending order by ReceivedDateTime. For example we have 15 new messages with ReceivedDateTime = n, where n represents date time.
In first part will come:
[15,14,13,12,11,10,9,8,7,6 (deltaHash="someValue")]
in second:
[5,4,3,2,1 (deltaHash=NULL)]
So, the oldest email will come the latest (LIFO, not FIFO).
But I expect to get:
[1,2,3,4,5,6,7,8,9,10 (deltaHash="someValue")]
[11,23,13,14,15 (deltaHash=NULL)]
What I tried: I tried OrderBy(string value).
For these two I get exceptions:
.OrderBy("ReceivedDateTime asc")
.OrderBy("ReceivedDateTime")
This is working fine:
.OrderBy("ReceivedDateTime desc")
but this is the same as default behavior and I think this is a bug actually. So there is no way to sort emails in ASC order.
How to solve on first look very simple and common requirement?
Looks like this is a known issue as specified in the documentation.
The only supported $orderby expression is
$orderby=receivedDateTime+desc. If you do not include an $orderby
expression, the return order is not guaranteed.
So for now you need to sort them on your end by writing your own code.
I can confirm that .OrderBy("ReceivedDateTime asc") is now working as of the version of the microsoft-graph API I am using which is 5.36.0
I would like to find public users on Twitter that have 0 followers. I was thinking of using https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-search, but this doesn't have a way to filter by number of followers. Are there any simple alternatives? (Otherwise, I might have to resort to using a graph/search based approach starting from a random point)
Well you didn't specify what library you are using to interact with the Twitter API. But regardless of which technology you're using, the underlying concept is the same. I will use tweepy library in python for my example.
Start by getting the public users using this. The return type is a list of user objects. The user object has several attributes which you can learn about here. For now we are interested in the followers_count attribute. Simply loop through the objects returned and check where the value of this attribute is 0.
Here's how the implementation would look like in python using tweepy library;
search_query = 'your search query here'
get_users = api.search_users(q = search_query)#Returns a list of user objects
for users in get_users:
if users.followers_count ==0:
#Do stuff if the user has 0 followers
Bird SQL by Perplexity AI allows you to do this simply: https://www.perplexity.ai/sql
Query: Users with 0 followers, and 0 following, with at least 5 tweets
SELECT user_url, full_name, followers_count, following_count, tweet_count
FROM users
WHERE (followers_count = 0)
AND (following_count = 0)
AND (tweet_count >= 5)
ORDER BY tweet_count DESC
LIMIT 10
I've a query that uses difference function and I can't understand why it returns no data.
The query is:
SELECT
difference(FIRST(grid_power_counter)) as grid_power_consumed
FROM homesolar.origin.main GROUP BY time(15m)
If I remove the difference function it returns data:
SELECT
FIRST(grid_power_counter) as grid_power_consumed
FROM homesolar.origin.main GROUP BY time(15m)
Also, I can get results if I add a where time > now()-24h to the select with difference function.
I really can't understand that behavior. Can someone help me?
Q: My query would only work if I add the where filter to it. Why is that so?
Quoted from influxdb's Groupby time doc:
Basic GROUP BY time() queries require an InfluxQL function in the
SELECT clause and a time range in the WHERE clause.
I suspect your first DIFFERENCE query didn't work because it was missing the mandatory WHERE filter for the Groupby time(...) function.
The Group by time() clause could be returning no rows and hence not.
This could potentially be a github issue for the influx team as I think their query parser should be complaining to you about the missing where filter for Group by time.
References:
https://docs.influxdata.com/influxdb/v1.5/query_language/data_exploration/#the-group-by-clause
I have framed query to submit to solr which is of following format.
id:95154 OR id:68209 OR id:89482 OR id:94233 OR id:112481 OR id:93843
i want to get records according to order from starting. say i need to get document with id 95154 document first then id 68209 next and so on. but its not happening right now its giving last id 93843 first and some times random.i am using solr in grails 2.1 and my solr version is 1.4.0. here is sample way i am getting documents from solr
def server = solrService.getServer('provider')
SolrQuery sponsorSolrQuery = new SolrQuery(solarQuery)
def queryResponse = server.query(sponsorSolrQuery);
documentsList = queryResponse.getResults()
As #injecteer mentions, there is nothing built-in to Lucene to consider the sequence of clauses in a boolean query, but:
You are able to apply boosts to each term, and as long as the field is a basic field (meaning, not a TextField), the boosts will apply cleanly to give you a decent sort by score.
id:95154^6 OR id:68209^5 OR id:89482^4 OR id:94233^3 OR id:112481^2 OR id:93843
there's no such thing in Lucene (I strongly assume, that in Solr as well). In Lucene you can sort the results based on contents of documents' fields, but not on the order of clauses in a query.
that means, that you have to sort the results yourself:
documentsList = queryResponse.getResults()
def sordedByIdOrder = solarQueryAsList.collect{ id -> documentList.find{ it.id == id } }
I'm trying to implement a trending feature on my app. I have a table called Search that has a keyword column. Every time a user uses the search function, the keyword is stored in the table as a row. What I did is I get the searches done for the past 4 hours, group them by keyword, limit the search to 6 keywords, and arrange them based on the number of occurrence of the keyword. At the moment, I'm using this query on the controller:
Search.where('created_at >= ?', 4.hours.ago).group(:keyword).order('count_keyword DESC').limit(6).count(:keyword)
I tried turning the same query into a named scope and here's what I got:
scope :trending, lambda { where('created_at >= ?', 4.hours.ago).group(:keyword).order('count_keyword DESC').limit(6).count(:keyword) }
The problem here is that I get this error:
ArgumentError: Unknown key: thesearchkeyword
I don't really know a lot about named scopes and reading the API doesn't help a lot since they only provide very simple examples. Could anyone point me in the right direction?