I am attempting to write a backfill script that will pull in historical follower numbers for linkedin companies we are missing data for. My current script is able to get data back from linkedin, but these numbers appear incorrect for my test company. I am using this company: https://www.linkedin.com/company/3802814
I make a historical follower statistics call like so:
http://api.linkedin.com/v1/companies/3802814/historical-follow-statistics?start-timestamp=315554400&end-timestamp=1421349947&time-granularity=day&format=json
(these timestamps correspond to 01/01/1980 and 01/15/2015)
The data I'm getting back indicates 14 (not 6, as my company actually has) followers, all on random/incorrect dates, with all 0s:
{
"_total": 14,
"values": [
{
"organicFollowerCount": 0,
"paidFollowerCount": 0,
"time": 259200000,
"totalFollowerCount": 0
},
{
"organicFollowerCount": 0,
"paidFollowerCount": 0,
"time": 345600000,
"totalFollowerCount": 0
},
... (10 more similar records)
{
"organicFollowerCount": 0,
"paidFollowerCount": 0,
"time": 1296000000,
"totalFollowerCount": 0
},
{
"organicFollowerCount": 0,
"paidFollowerCount": 0,
"time": 1382400000,
"totalFollowerCount": 0
}
]
}
I would have guessed my timestamps were wrong until I saw that it's giving me more followers than I should actually have. Does anyone know what I might be doing wrong? Looking at the linkedin docs has thus far not given me any obvious answers. Data I expect would be a series of daily records updated by # of followers added on a given day. These followers were primarily added sometime in December 2014.
This is the proper request you should be making to get the information you are looking for:
GET https://api.linkedin.com/v1/companies/3802814/historical-follow-statistics?start-timestamp=315561600000&time-granularity=day&end-timestamp=1421308800000&format=json
You want to make sure you are using the timestamps in milliseconds.
The total value you are also seeing is the # of results - not the # of followers.
Related
I'm trying to decide how to model data in firestore.
Basically, it's for an app that lists happy hours and other specials that restaurants have. Each restaurant/bar could have multiple specials and happy hours depending on the day of the week.
This is a very simplified example of how I was hoping to model the data:
name: "Margaritaville",
geo: {
latitude: 42,
longitude: -105
},
offers {
0: {Type: Happy Hours, Time: 3p-6p, Mon: 1, Tue: 1, Wed: 1, Thu: 1, Fri: 0, Sat: 0, Sun: 0 },
1: {Type: Happy Hours, Time: 2p-5p, Mon: 0, Tue: 0, Wed: 0, Thu: 0, Fri: 1, Sat: 1, Sun: 0},
2: {Type: Happy Hours, Time: All Day, Mon: 0, Tue: 0, Wed: 0, Thu: 0, Fri: 0, Sat: 0, Sun: 1},
3: {Type: Brunch Special, Time: 11a-2p, Mon: 0, Tue: 0, Wed: 0, Thu: 0, Fri: 0, Sat: 0, Sun: 1}
},
etc: "foo",
etc: "bar"
I WANTED to store all the offers data as a nested object inside each business document rather than as a separate collection, as most of the queries will require most of this information along with the lat/long, photos, name, etc. But...
I ultimately want to be able to do query filters by day of the week (Mon, Tue, etc) and offer times and offer types (Happy Hours, Brunch) and distance from user, etc. The way the info is modeled now however, the "offers" that are created inside each document, are ordered (0, 1, 2 etc), so if I wanted to perform a query of all restaurants within 10 miles that have happy hour specials on Monday, for example, I was hoping to do something like this:
db.collection("restaurants").where("offers.WILDCARD.days.Mon", "==", 1)
Note, the "WILDCARD" above. Is there any way to make this work, or do I have to move offers to a separate collection or subcollection? I've been trying to wrap my head around de-normalization, I've only ever worked with SQL databases, so I'm open to advice with regard to how I should be thinking about this.
Firestore doesn't support any wildcards in queries. Furthermore, if your "offers" field is an array, you won't be able to query any of its nested object contents.
What you should do instead is break out "offers" into a subcollection, with each of its elements being a new document in that subcollection. You can query the subcollection for matches against the document properties. If you find a match, then you can do a second get() to find the parent document if needed.
I'm pretty new to Angular. I'm using Moments.js to get the difference between to times. Using duration it returns a object structured like this
Duration {_isValid: false, _milliseconds: 0, _days: 0, _months: 0, _data:
_data:
days: 0
hours: 0
milliseconds: 0
minutes: 0
months: 0
seconds: 0
years: 0
__proto__: Object
I'm trying to access the hours value and doing it by
const time = time._data.hours
It is giving me an error that _data does not exists on type Duration, however the value is showing.
How would I fix this?
You dont want to use the _data object. You want to call into the function and get the value in hours...
moment.duration(2, 'hours');
https://momentjs.com/docs/#/durations/
Also momentJS is NOT affiliated with Angular.
Thanks!
I'm new to NoSQL database. Currently I'm trying to use the Firebase and integrate it with iOS. When it comes to predefine the database, with trial and error, I try to make it look like this:
When I tried to retrieve the "stories" path in iOS, I get json structure like this:
[
<null>,
{
comments: [
<null>,
1,
2,
3
],
desc: "Blue versus red in a classic battle of good versus evil and right versus wrong.",
duration: 30,
rating: 4.42,
tags: [
<null>,
"fantasy",
"scifi"
title: "The Order of the Midnight Sun",
writer: 1
]
}
]
My question is, why there's always a null at the beginning of each array? What should I do in the database editor to avoid the null?
It looks like you start pushing data to index 1 and not 0, inserting/retrieving data to/from a list starts with index 0:
In my app I have some videos and users can like it. video metadata saves in the node "videos", something like this:
videos: {
xxxxx: {
name: "Funny video",
likes: 255,
....
}
}
And I have another node "userVideos" only with video ids.
userVideos: {
xxxxx: true,
yyyyy: true,
}
In the UI I want to show the ranking of the video. For example, I have 5 videos: v01 has 5 likes, v02 - 10, v03 - 1, v04 - 100, v05 - 3.
So, when I get from userVideos the video with id "v03", I should know that his ranking is 5 ('cause if I get the videos list with orderBy DESC my videos node, the position of v03 is 5).
I think that the cloud function should calculate this ranking.
My question is next: is I have a possibility to get the position in the sorted node by key?
Realtime Database queries can't tell you the position of a child snapshot in a sorted query. You have to write code to maintain that data for yourself.
I am trying to setup Kibana dashboard.
In Elasticsearch, there is one type of document only.
We have two indices with the same mapping:
Indices product_1 and product_2:
"_index": "product_1",
"_type": "product",
"_id": "3da33451d10f095c4b8cd485133dc23639244538",
"_score": 1,
"_source": {
...
source": { "brand": "","category": "","store": "Store1"}
...
}
"_index": "product_1",
"_type": "product",
"_id": "3da33451d10f095c4b8cd485133dc23639244538",
"_score": 1,
"_source": {
...
source": { "brand": "","category": "","store": "Store2"}
...
}
...
We have managed to create follow visualization.
We need to count total quantity of products (documents) per field store:
Top 0 source.store Count
Store1 52,517
Store2 31,517
Store3 12,838
...
So, question is: How do we add data from second index here, in order to get result like that:
Top 0 source.store Count (product_1) Count (product_2)
Store1 52,517 42,517
Store2 31,517 56,517
Store3 12,838 13,890
...
Thanks a lot.
PS: We have managed to collect data from 2 indices:
["product_1","product_2"]
So kibana sources data, as if it is one index, and we get follow wrong result:
Top 0 source.store Count (product_1+product_2)
Store1 102,517
Store2 62,517
Store3 24,838
...
I am not entirely sure if what you are trying is even possible. From the elastic search index documentation:
The easiest and most familiar layout clones what you would expect from a relational database.
You can (very roughly) think of an index like a database.
MySQL => Databases => Tables => Columns/Rows
Elasticsearch => Indices => Types => Documents with Properties
And as I understand here, you are trying to get data from two databases(indices) in a single query, which to the best of my knowledge, is not possible - at least the way you want it, i.e. assort results according to indices.
Now you might (should) have a question that if that is entirely impossible, how did you get the following results?
Top 0 source.store Count (product_1+product_2)
Store1 102,517
Store2 62,517
Store3 24,838
This is where the Kibana magic lies. You can create an index pattern with a wild card. That will query every index that falls within the card. For example creating logstash-* will query all the logstash-[date] indices and give out consolidated results that you see. In your case it can be achieved by creating an index pattern as product_*. But I think you cannot get index wise assorted results with that (which I suppose, is exactly what you're looking for).