I'm using this URL:
https://api.linkedin.com/rest/adAnalytics?q=analytics&dateRange.start.day=1&dateRange.start.month=1&dateRange.start.year=2022&timeGranularity=MONTHLY&companies=urn%3Ali%3Aorganization%3A{ORG_ID}&pivot=ACCOUNT
And the answer I get is like:
{'clicks': 54, 'impressions': 19227, 'pivotValues': ['urn:li:sponsoredAccount:{ACCOUNT_ID}'], 'dateRange': {'start': {'month': 4, 'day': 1, 'year': 2022}, 'end': {'month': 4, 'day': 30, 'year': 2022}}}
The documentation (https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/ads-reporting?view=li-lms-2022-11&tabs=http) states that there is a ton of metrics, but I only get those two: 'clicks' and 'impressions'.
Why is that?
As it turns out, the number of metrics that can be obtained is 20 and in order to get the metrics you have to add a query parameter 'fields' in which you put the names of desired metric one after another, separated by commas.
may i know where is the fields you put at? is after the pivot or remove the pivot direct replace it to fields?
Related
What is the correct way to store date/time stamp in a gremlin-based database like Amazon Neptune?
When I try the following in python
current_timestamp = datetime.datetime.now()
g.E('d').property('otp_verified_on', current_timestamp).next()
it gives me output, something similar to
'otp_verified_on': datetime.datetime(2021, 11, 23, 9, 47, 30, 173000)
so I type cast to string
current_timestamp = datetime.datetime.now()
g.E('d').property('otp_verified_on', str(current_timestamp)).next()
to get the following result
'otp_verified_on': '2021-11-23 08:27:45.867543'
My queries are based on date comparison operation gte, lte`, etc...
Which is the better/correct way to implement?
Neptune will convert Python dates into an appropriate internal form and you can do evaluations directly on the dates. Here is a set of examples. You do not need to (and should not) cast to strings. An alternative is to store epoch offset integers but in the case of Neptune, using the native Python dates will be slightly more efficient in terms of how the computations are performed. You should check the documentation for each database you may use but in the case of Neptune using the native Python datetime is the best way to go.
>>> import datetime
>>> g.addV('test').property('ts',datetime.datetime.now()).next()
v[eebec326-001f-577b-0893-bbd0ddf5e271]
>>> g.addV('test').property('ts',datetime.datetime.now()).next()
v[3ebec326-0628-8b3a-5d4e-9d7292075072]
>>> g.V().hasLabel('test').valueMap(True).toList()
[{<T.id: 1>: 'eebec326-001f-577b-0893-bbd0ddf5e271', <T.label: 4>: 'test', 'ts': [datetime.datetime(2021, 12, 4, 10, 34, 27, 448000)]},
{<T.id: 1>: '3ebec326-0628-8b3a-5d4e-9d7292075072', <T.label: 4>: 'test', 'ts': [datetime.datetime(2021, 12, 4, 10, 34, 30, 589000)]}]
>>> g.V().hasLabel('test').has('ts',lt(datetime.datetime.now())).toList()
[v[eebec326-001f-577b-0893-bbd0ddf5e271], v[3ebec326-0628-8b3a-5d4e-9d7292075072]]
>>> g.V().hasLabel('test').has('ts',gt(datetime.datetime.now())).toList()
[]
My graph schema looks like this:
(Location)<-[:INVENTOR_LOCATED_IN]-(Inventor)-[:INVENTOR_OF]->(Patent)
I'm trying to return multiple values from each step in the query path. Here's the query I have so far that runs correctly:
g.V().and(has('Location', 'city', textContains('Bloomington')), has('Location','state',textContains('IN'))).as('a').
bothE().bothV().hasLabel('Inventor').as('b').
bothE().bothV().has('Patent', 'title', textContains('Lid')).as('c').
select('a,', 'b', 'c').
by('state').by('name_first').by('title').
fold();
What I would like to do is for each step return two node properties. I tried the following but it returns an error:
g.V().and(has('Location', 'city', textContains('Bloomington')), has('Location', 'state',textContains('IN'))).as('a').
bothE().bothV().hasLabel('Inventor').as('b').
bothE().bothV().has('Patent', 'title', textContains('Lid')).as('c').
select('a,', 'b', 'c').
by('city', 'state').by('name_first', 'name_last').by('title', 'abstract').
fold();
Can anyone suggest syntax that will allow me to return multiple properties from each node in the path?
The by(key) is meant to be a sort of shorthand for values(key) which means if you have more than one value you could do:
g.V().and(has('Location', 'city', textContains('Bloomington')), has('Location', 'state',textContains('IN'))).as('a').
bothE().bothV().hasLabel('Inventor').as('b').
bothE().bothV().has('Patent', 'title', textContains('Lid')).as('c').
select('a,', 'b', 'c').
by(values('city', 'state').fold()).
by(values('name_first', 'name_last').fold()).
by(values('title', 'abstract').fold()).
fold()
You might also consider forms of elementMap(), valueMap(), or project() as alternatives. Since by() takes a Traversal you have a lot of flexibility.
I really hope someone can explain this for me.
I have set up a script that makes requests to the Google Analytics Reporting API V.4.0. using Python to fetch session data. However, depending on what date range I use, some dates return different number of rows.
For example, when requesting data for (in this case) 2018-05-17, I get 41 rows. The number of rows for that day stay at 41 if I extend the date range slightly, but if I go too far, say from 2018-05-01 to 2018-07-10, then the number of rows for 2018-05-17 suddenly change from 41 to 40. One row is missing and I get no clue that it happens, and certainly not to why it happens.
I don't get any indication that the data is sampled (samplesReadCounts and samplesReadCounts are both undefined). I have also taken care of pagination by making consecutive requests with pageToken set to the previous nextPageToken value (unless pageSize is high enough, as it is in the request below). I also get the correct number of rows for all other dates in the date range (compared to the number of rows returned with the date range set to each single date).
This is the body I use for this specific request (dummy viewId):
{'reportRequests': [{'viewId': '123456789',
'dateRanges': [{'startDate': '2018-05-01', 'endDate': '2018-07-10'}],
'dimensions': [{'name': 'ga:date'},
{'name': 'ga:sourceMedium'},
{'name': 'ga:campaign'},
{'name': 'ga:deviceCategory'}],
'metrics': [{'expression': 'ga:sessions'},
{'expression': 'ga:pageviews'},
{'expression': 'ga:bounces'},
{'expression': 'ga:sessionDuration'},
{'expression': 'ga:newUsers'}],
'pageToken': '0',
'pageSize': '10000',
'includeEmptyRows': True,
'hideTotals': True,
'hideValueRanges': True}]}
And this is the response with all rows stripped:
{'columnHeader': {'dimensions': ['ga:date',
'ga:sourceMedium',
'ga:campaign',
'ga:deviceCategory'],
'metricHeader': {'metricHeaderEntries': [{'name': 'ga:sessions',
'type': 'INTEGER'},
{'name': 'ga:pageviews', 'type': 'INTEGER'},
{'name': 'ga:bounces', 'type': 'INTEGER'},
{'name': 'ga:sessionDuration', 'type': 'TIME'},
{'name': 'ga:newUsers', 'type': 'INTEGER'}]}},
'data': {'rows': [], 'rowCount': 3817, 'isDataGolden': True}}
I can see no indication that the data should not be complete and correct. But still, one row is missing.
Hi, I have an excel sheet like the one posted above. I am trying to retrieve data from this spreadsheet and insert it into a database. An example of a few entries would be,
[personnel_no: 35, name: John, Day: 01, Value: N],
[personnel_no: 35, name: John, Day: 02, Value: N],
[personnel_no: 35, name: John, Day: 03, Value: O]
I know how to create a loop that will go through the spreadsheet by rowss but i'm stumped as to how to do it by column. I've read that phpexcel has a column iterator function but im not even sure how to do that.
Unsure why you even need the column iterator for this, because all your data is tabulated by row....
$worksheet = $objPHPExcel->getActiveSheet();
foreach ($worksheet->getRowIterator() as $row) {
$rowData = $worksheet->toArray('A'.$row->getRowIndex().':AG'.$row->getRowIndex());
... var_dump($rowData);
... insert data from $rowData into the database
}
If you want to read more about iterators, take a look at 28iterator.php in /Examples
I have a question to couchdb views / map-reduce.
Lets say, we have a database with hotel-documents like the following:
[{
_id: "1",
name: "Hotel A",
type: "hotel",
stars: 3,
flags: ["family-friendly","green-hotel","sport"],
hotelType: "premium",
food: ["breakfast","lunch"]
}, {
_id: "2",
name: "Hotel B",
type: "hotel",
stars: 5,
flags: ["family-friendly","pet-friendly"],
hotelType: "budget",
food: ["breakfast","lunch","dinner"]
}]
To find all hotels with 3 stars, the following view will fit:
function(doc) {
emit([doc.stars, doc.name]);
}
If I use startkey=[3], everything is fine.
But how is it possible to make a view with multiple filters?
For example - all hotels:
with 3 stars and the flags "family-friendly" and "pet-friendly" and
with hotelType "budget"?
with hotelType "premium" and food "breakfast" or "lunch"?
etc.
Any ideas?
EDIT:
I have now decided to use good old mysql. CouchDB was a nice experience for me, but there are tooo much problems if you need more then the data of one document :(
You can emit a key with a group of values:
emit([[doc.stars,doc.hotelType], doc.name]);
The problem is that this only works if you can order your attributes by importance since they will always get reduced in the same order. Kxepal's solution of using different views is probably the best for your situation.
Source: http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views#Grouping
You need to use different views for that. Each view will handle his own domain with own keys. You may create one-view-for-all-data via multiple emit with different key value, but in perspective it will be hard to maintain.
CouchDB views are one-dimensional. And you are looking for multi-dimensional query:
x = stars
y = flags
z = hotelType
Multi-dimensional queries are not supported unfortunately. For example if you need query geographical location by latitude and longitude, than you'll have to use GeoCouch.