How to remove duplicates based on property after an aggregate query? - mongodb

I'm trying to figure out how to remove duplicates based on the url, as the aggregate query can match the same document twice if say "APPL" and "TSLA" are in stocks and included in the same document.
const res = await ReadSchema.find({ 'tickers.symbol': { $in: stocks } })
.select(['-content', '-htm'])
.sort({ createdAt: -1 })
.limit(100)
.filter((v, i, a) => a.findIndex((t) => t.url === v.url) === i);
I'm doing this in js after the results, but I'd rather do it before the .limit(100) so that I remove duplicate urls before I grab the first 100.
Here is an example document:
{
"_id" : ObjectId("6001eb414110e6001cb5b226"),
"summary" : {
"topics" : [
"buds",
"pro",
"galaxy",
"anc",
"live",
"sound",
"samsung",
"noise",
"ear",
"app"
],
"sentiment" : 0,
"words" : 0,
"difficulty" : 0,
"minutes" : 0
},
"views" : 1,
"title" : "Samsung takes on Apple's AirPods Pro with new Galaxy Buds Pro",
"byline" : "Alex Perry",
"dir" : null,
"content" : "<div id=\"readability-page-1\" class=\"page\"><section>\n\n<p>Sometimes making things less fun is for the best. Case in point: The Samsung Galaxy Buds Pro. </p>\n<p>Just a handful of months after Samsung graced us with the delightfully bean-shaped (and genuinely good) Galaxy Buds Live, we've already got a more, uh, \"professional\" follow-up. At $199.99, the Galaxy Buds Pro are only marginally more expensive than the Buds Live, but offer a totally different look and a few extra features, largely revolving around active noise cancellation.</p>\n<p>The end result is something that should please Samsung fans (and Android users in general). But is there any reason to spend that extra $30 instead of getting the <em>already totally fine</em> Galaxy Buds Live? </p>\n<div>\n\n<div>\n<div>\n<div>\n<p>\nMuch more comfortable than Buds Live • Improved ANC • Sound quality is still great • Strong app-based customization\n</p></div>\n<div>\n<p>\nVoice detection feature is a dud • ANC struggles with outdoor bustle\n</p></div>\n\n</div>\n\n\n\n</div>\n</div>\n\n<h2>The Good: Improved ANC and comfort, SmartThings Find, sound quality</h2>\n<p>The most noticeable difference between the Buds Live and the Buds Pro from the jump is their appearance. As we've discussed, the Buds Live were shaped like something you'd find in a burrito and, on a practical level, let a decent amount of outside noise in due to the lack of a seal of any kind. Their ANC features did a little bit to offset this, but it wasn't good enough. It was pretty sweet that they attracted next to no earwax because they didn't actually go inside the ear, though.</p>\n<p>The Buds Pro aren't nearly as eye-catching but they make up for it in the ways that actually matter. Like Apple's AirPods Pro equivalent, the Buds Pro have rubber ear cups that you insert into the ear canal with a rounded touch panel that sits outside featuring basic playback controls. Tap once to pause, tap twice to skip ahead, and so on. Samsung is shipping the Buds Pro with three different ear cup sizes to accommodate different ear shapes, as well.</p>\n<div>\n<div>\n\n<figure><div>\n <p><img alt=\"Galaxy Buds Live\" data-fragment=\"m!0fdc\" data-image=\"https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591715%252F873bf2ac-34d3-4a4a-b2cd-f3befe3f05fe.png%252Ffull-fit-in__1200x2000.png?signature=NZalyPHmMKjSvE_-Md19lx1Ovfk=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com\" data-micro=\"1\" loading=\"lazy\" naturalwidth=\"950\" sizes=\"(max-width: 300px) 280w,(max-width: 400px) 356w,(max-width: 700px) 638w,950w\" src=\"https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591715%252F873bf2ac-34d3-4a4a-b2cd-f3befe3f05fe.png%252Ffull-fit-in__950x534.png?signature=0P5F2WHmrx7IopVdxva_M-CrBCs=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com\" src_type=\"png\" srcset=\"https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591715%252F873bf2ac-34d3-4a4a-b2cd-f3befe3f05fe.png%252Ffull-fit-in__280x157.png?signature=KLY0Uk8B1s5bL03gF9ehpT1HFM4=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 280w,https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591715%252F873bf2ac-34d3-4a4a-b2cd-f3befe3f05fe.png%252Ffull-fit-in__356x205.png?signature=Z-q_8wMfWcP-cbOWGMcJOcIcps0=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 356w,https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591715%252F873bf2ac-34d3-4a4a-b2cd-f3befe3f05fe.png%252Ffull-fit-in__638x368.png?signature=dUn8anfa1mPCeLNJAwiejq4X83E=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 638w,https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591715%252F873bf2ac-34d3-4a4a-b2cd-f3befe3f05fe.png%252Ffull-fit-in__950x534.png?signature=0P5F2WHmrx7IopVdxva_M-CrBCs=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 950w\">\n</p></div>\n\n\n<figcaption><p>Galaxy Buds Live\n</p></figcaption><p>Image: alex perry / mashable\n</p></figure>\n</div>\n<div>\n\n<figure><div>\n <p><img alt=\"Galaxy Buds Pro\" data-fragment=\"m!a70e\" data-image=\"https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591722%252Fb72cbc58-58fc-484c-8a54-fae6c2306ebc.jpg%252Ffull-fit-in__1200x2000.jpg?signature=dFshI8fkvoBN6_Rg8ZYPqfRwxb4=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com\" data-micro=\"1\" loading=\"lazy\" naturalwidth=\"950\" sizes=\"(max-width: 300px) 280w,(max-width: 400px) 356w,(max-width: 700px) 638w,950w\" src=\"https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591722%252Fb72cbc58-58fc-484c-8a54-fae6c2306ebc.jpg%252Ffull-fit-in__950x534.jpg?signature=SpjFrkhxftv8Z4eGTzVzosVqvhI=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com\" src_type=\"jpg\" srcset=\"https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591722%252Fb72cbc58-58fc-484c-8a54-fae6c2306ebc.jpg%252Ffull-fit-in__280x157.jpg?signature=HXfNokeRqH-JA92c1-GP_w-fQlI=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 280w,https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591722%252Fb72cbc58-58fc-484c-8a54-fae6c2306ebc.jpg%252Ffull-fit-in__356x205.jpg?signature=d2iT0s-p_vsJpWa0pK1kHpbm6Qg=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 356w,https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591722%252Fb72cbc58-58fc-484c-8a54-fae6c2306ebc.jpg%252Ffull-fit-in__638x368.jpg?signature=5eWyZZdHOKWwE4y2-2ogtFJHUg4=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 638w,https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591722%252Fb72cbc58-58fc-484c-8a54-fae6c2306ebc.jpg%252Ffull-fit-in__950x534.jpg?signature=SpjFrkhxftv8Z4eGTzVzosVqvhI=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 950w\">\n</p></div>\n\n\n<figcaption><p>Galaxy Buds Pro\n</p></figcaption><p>Image: alex perry / mashable\n</p></figure>\n</div>\n</div>\n<p>From a purely physical standpoint, the Buds Pro are fundamentally a step up from the Buds Live because of how much better they feel in the ear. The \"beans\" fit snugly and were never a threat to fall out, but the insides of my ears didn't appreciate long sessions with them, and signaled that with minor aching. By virtue of keeping hard plastic away from the sensitive skin inside my ears, the Buds Pro were <em>significantly</em> more comfortable for lengthy periods of time. </p>\n<p>The ear tips not only make the Buds Pro more comfortable, but they also do a much better job of blocking unwanted outside noise than the Buds Live's open form factor did. While the ANC here still isn't perfect (more on that in a bit), it's a real improvement. When it's enabled and you're not in close proximity to chaos, you'll be able to listen to your music or podcasts in peace.</p>\n<p>Just like the Buds Live, Samsung's newest earbuds can connect to the Galaxy Wearable Android app for all of your settings and customization needs. That app is Android-only, so iPhone owners should probably buy some AirPods instead. Within the Wearable app you can set ANC to high or low (I didn't notice a huge difference between the two), turn it off entirely, or turn on an ambient sound mode that uses the on-board microphones to amplify sounds around you in situations where you might need to hear what people are saying. </p>\n<p>Beyond that, you can adjust what the long-press command on the earbuds' outer panels does (taps are set in stone), choose from a handful of different equalizer options like \"bass boost\" and \"treble boost,\" or even shift the audio balance to favor the left or right side if your hearing is better in one ear than the other. This amount of customization was a strong aspect of the Buds Live and it's still strong here, as well. It isn't super different, but it's appreciated nonetheless.</p>\n<p>Another side of the Buds Pro that picks up where Buds Live left off is sound quality. I was really impressed with how deep and rich the sound was in the \"beans\" despite their unusual shape. That hasn't changed with the shift to a more traditional build. The audio output here isn't dramatically better than what I experienced in the \"beans,\" but the 11mm woofer and 6.5mm tweeter inside do an excellent job of making songs sound like they should. </p>\n<figure><div>\n <p><img alt=\"The Galaxy Wearable app\" data-fragment=\"m!beae\" data-image=\"https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591421%252Fc7dad555-1148-4700-8268-77002a63f642.jpg%252Foriginal.jpg?signature=mVprQdLxhltKq-tGPj21dYhKOzk=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com\" data-micro=\"1\" loading=\"lazy\" naturalwidth=\"950\" sizes=\"(max-width: 300px) 280w,(max-width: 400px) 356w,(max-width: 700px) 638w,950w\" src=\"https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591421%252Fc7dad555-1148-4700-8268-77002a63f642.jpg%252Ffull-fit-in__950x534.jpg?signature=cZGICWc0BfWlzHT4dBKEa7BDPos=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com\" src_type=\"jpg\" srcset=\"https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591421%252Fc7dad555-1148-4700-8268-77002a63f642.jpg%252Ffull-fit-in__280x157.jpg?signature=I9LxxqU9xNEBTe6ZDZ3x8Pf6MFo=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 280w,https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591421%252Fc7dad555-1148-4700-8268-77002a63f642.jpg%252Ffull-fit-in__356x205.jpg?signature=Vxxu-64ZaXie39nPyghsfKgryA0=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 356w,https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591421%252Fc7dad555-1148-4700-8268-77002a63f642.jpg%252Ffull-fit-in__638x368.jpg?signature=6fP9FBkiCqJdSAbT6qOBW6EOT2s=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 638w,https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591421%252Fc7dad555-1148-4700-8268-77002a63f642.jpg%252Ffull-fit-in__950x534.jpg?signature=cZGICWc0BfWlzHT4dBKEa7BDPos=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 950w\">\n</p></div>\n\n\n<figcaption><p>The Galaxy Wearable app\n</p></figcaption><p>Image: alex perry / mashable\n</p></figure><p>Instruments and vocals at the front of the mix are appropriately prominent, while aspects of a song that fill out the sound without calling much attention to themselves are fully audible if you focus on them. Some wireless earbuds can flatten songs out due to small, chintzy speakers, but the Buds Pro avoid that particular pitfall. I would still say the Bose QC Earbuds are <em>slightly</em> richer in sound, but they're also $80 more expensive. </p>\n<p>Battery life is also acceptable, if not remarkable. People who like to use ANC will notice battery drain, as the Buds Pro are rated for about five hours of ANC listening time with an additional 13 hours in the charging case, which is in line with my experience. Turn ANC off and you should get closer to eight hours on a single charge, so if you can live without that key feature, you'll have a better time.</p>\n<p>Oh, and one last thing: Galaxy Buds Pro work with Samsung's recently launched device tracking feature within the SmartThings app. SmartThings Find will show you a GPS location for your Buds Pro even if they're off. If they get lost or stolen, this is huge. Simply open the SmartThings app while the Buds Pro are paired to the phone to pair them to the app. It's quick, easy, and eminently useful.</p>\n<h2>The Bad: Sensitive voice detection, ANC is better indoors than outdoors</h2>\n<figure><div>\n <p><img alt=\"The case is almost identical to the Buds Live case.\" data-fragment=\"m!6d74\" data-image=\"https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591414%252F2bf3f78c-75f9-4720-af0b-0e8494231004.jpg%252Foriginal.jpg?signature=c1GLO0Mcnadapz4KHB3k_jiZgB0=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com\" data-micro=\"1\" loading=\"lazy\" naturalwidth=\"950\" sizes=\"(max-width: 300px) 280w,(max-width: 400px) 356w,(max-width: 700px) 638w,950w\" src=\"https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591414%252F2bf3f78c-75f9-4720-af0b-0e8494231004.jpg%252Ffull-fit-in__950x534.jpg?signature=qMk3EQVFbzAZSCBsJrTc1Hpg5V0=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com\" src_type=\"jpg\" srcset=\"https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591414%252F2bf3f78c-75f9-4720-af0b-0e8494231004.jpg%252Ffull-fit-in__280x157.jpg?signature=sKmiyBUFQdAvwwN_hQDYwFSCOGo=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 280w,https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591414%252F2bf3f78c-75f9-4720-af0b-0e8494231004.jpg%252Ffull-fit-in__356x205.jpg?signature=MrGzmcAVT-ha4f0pyB_cjLjtaV8=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 356w,https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591414%252F2bf3f78c-75f9-4720-af0b-0e8494231004.jpg%252Ffull-fit-in__638x368.jpg?signature=K03SKbqjuUqgjS0hTi-xENqm3Js=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 638w,https://mondrian.mashable.com/uploads%252Fcard%252Fimage%252F1591414%252F2bf3f78c-75f9-4720-af0b-0e8494231004.jpg%252Ffull-fit-in__950x534.jpg?signature=qMk3EQVFbzAZSCBsJrTc1Hpg5V0=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com 950w\">\n</p></div>\n\n\n<figcaption><p>The case is almost identical to the Buds Live case.\n</p></figcaption><p>Image: alex perry / mashable\n</p></figure><p>Unfortunately, one of the more distinct ANC-centric features of the Buds Pro was a dud for me. Samsung is touting the \"voice detect\" feature (enabled in the Galaxy Wearable app) as a way to get through your day without constantly turning ANC on or off, but I ended up keeping the feature disabled entirely. </p>\n<p>The way it works is that the Buds Pro can detect when you start speaking, at which point they will turn whatever you're listening to down and turn on the ambient noise mode so you can theoretically carry a conversation for a moment. Once you stop speaking for 10 seconds, everything goes back to the way it was. My issue is that it reacted a little too sensitively to things like sighing and clearing my throat, which would then ruin a song I was listening to for 10 seconds. </p>\n<p>I wish there were a way to shorten the time before ambient sound turns off, but for now, 10 seconds is the only option you have. I can see people getting use out of this, but personally, I found it more useful to long press one of the earbuds to manually turn ambient sound mode on or off.</p>\n<p>The only other minor criticism I have is less of a specific problem with the Buds Pro and more of a general issue with noise-cancelling wireless earbuds. Samsung's ANC here is better than it was in the previous model, but it can still let too much noise in when you're walking down a busy street. In other words, you can drown out the noise of an office or an apartment, but cars whizzing by you will still make noise. Use over-ear noise-cancelling headphones if you want to <em>really</em> escape from the world.</p>\n<h2>The Verdict</h2>\n<p>If I owned a Samsung smartphone, the Galaxy Buds Pro would be a no-brainer for me. They work just as seamlessly with something like a Galaxy Note 20 (which I used for testing) as AirPods do with an iPhone, provide terrific sound quality and noise cancellation, and can sit in my ears for hours at a time without bothering me. The improved ANC and additional comfort are enough to make me wholeheartedly recommend these over the Galaxy Buds Live for Android owners.</p>\n<p>That said, I wish the ANC did a better job of muting louder outdoor noises, but maybe that's a few years away. It's also unfortunate that the voice detection feature can be more of a hindrance than a help, at least in my experience. Despite those minor issues, as well as middling battery life when ANC is turned on, the Galaxy Buds Pro are a worthy successor to the Galaxy Buds Live and something Android owners should consider.</p>\n<p>With all due respect to the \"beans,\" this is a case where boring is better.</p>\n<h2>WATCH: Unboxing the BTS Edition Samsung Galaxy Buds+</h2>\n<div data-source=\"blueprint\" data-template=\"embedded\" data-video=\"O4oKA2YZnd\">\n<div>\n <p><img alt=\"Uploads%252fvideo uploaders%252fdistribution thumb%252fimage%252f95136%252f96587d2f 7dea 48ef 87c8 0ed74bd00239.png%252f930x520.png?signature=dkg2rtrnetqd20fsap ou2byynm=&source=https%3a%2f%2fblueprint api production.s3.amazonaws\" src=\"https://mondrian.mashable.com/uploads%252Fvideo_uploaders%252Fdistribution_thumb%252Fimage%252F95136%252F96587d2f-7dea-48ef-87c8-0ed74bd00239.png%252F930x520.png?signature=dkg2rtRNEtQd20FSap-Ou2bYYnM=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com\" data-fragment=\"m!3c0b\" data-image=\"https://mondrian.mashable.com/uploads%252Fvideo_uploaders%252Fdistribution_thumb%252Fimage%252F95136%252F96587d2f-7dea-48ef-87c8-0ed74bd00239.png%252Foriginal.png?signature=b1YV-6FyrAnr5O_ELQa8Vr7FPPE=&source=https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com\" data-micro=\"1\">\n</p></div>\n\n</div>\n\n\n\n</section></div>",
"length" : 8417,
"excerpt" : "Samsung's newest earbuds are less fun to look at, but better to use.",
"siteName" : "Mashable",
"tickers" : [
{
"_id" : ObjectId("6001eb414110e6001cb5b227"),
"name" : "Apple Inc.",
"symbol" : "AAPL",
"exchange" : "nasdaq"
}
],
"cryptos" : [
{
"_id" : ObjectId("6001eb414110e6001cb5b228"),
"name" : "Strong",
"symbol" : "STRONG"
},
{
"_id" : ObjectId("6001eb414110e6001cb5b229"),
"name" : "Tap",
"symbol" : "XTP"
}
],
"meta" : {
"title" : "Samsung takes on Apple's AirPods Pro with new Galaxy Buds Pro",
"thumb" : "https://mondrian.mashable.com/2021%252F01%252F15%252Fdd%252Fac21db42899b4219ab9b4e35fc74c043.002a7.jpg%252F1200x630.jpg?signature=I4q1zJF08njPyxmiZgxnHrSsTsM="
},
"url" : "https://mashable.com/review/samsung-galaxy-buds-pro-review/",
"host" : "mashable.com",
"createdAt" : ISODate("2021-01-15T19:21:37.931Z"),
"updatedAt" : ISODate("2021-01-15T19:21:37.931Z"),
"__v" : 0
}

You can use $group stage after $match stage,
$group by url and get first root document using $$ROOT, this will return document in root field
{
$group: {
_id: "$url",
root: { $first: "$$ROOT" }
}
}
this is optional, if you want to replace this root document to root, try $replaceRoot,
{ $replaceRoot: { newRoot: "$root" } }
Your final query would be,
const res = await ReadSchema.aggregate([
{ $match: { "tickers.symbol": { $in: stocks } } },
{
$group: {
_id: "$url",
root: { $first: "$$ROOT" }
}
},
{ $sort: { "root.createdAt": -1 } },
{ $limit: 100 },
{
$project: {
content: 0,
htm: 0
}
},
{ $replaceRoot: { newRoot: "$root" } }
])
Playground

await ReadSchema.aggregate([
{ $match: { 'tickers.symbol': { $in: stocks } } },
{
$project: {
content: 0,
htm: 0,
},
},
{
$group: {
_id: '$url',
root: { $first: '$$ROOT' },
},
},
{ $sort: { 'root.createdAt': -1 } },
{ $limit: 50 },
{ $replaceRoot: { newRoot: '$root' } },
]).allowDiskUse(true);
```

Related

Bing Truck Routing API - travelDistance units

We're dipping our toes into the Truck Routing API, and have a question on the units used in the travelDistance element of the regionTravelSummary.
Example GET request
https://dev.virtualearth.net/REST/v1/Routes/Truck?wayPoint.1=85710&waypoint.2=80634&routeAttributes=regionTravelSummary&distanceUnit=mi&vehicleTrailers=1&key=
What's interesting is in the routeLegs.RegionTravelSummary, the travelDistance is not in Miles (or kilometers, or anything I can figure out). Here's a snippet of the JSON:
"regionTravelSummary":[
{
"name":"United States",
"subregions":[
{
"name":"Arizona",
"travelDistance":818486183.9,
"travelDuration":22151,
"travelDurationTraffic":22151
},
{
"name":"New Mexico",
"travelDistance":1019336643.92,
"travelDuration":19460,
"travelDurationTraffic":19460
},
{
"name":"Colorado",
"tollDistance":11959005.54,
"travelDistance":702204931.54,
"travelDuration":14428,
"travelDurationTraffic":14428
}
],
"tollDistance":11959005.54,
"travelDistance":2540027759.36,
"travelDuration":56038,
"travelDurationTraffic":56038
}
]
What am I looking at here? The travelDistance in the primary resources array is correctly showing 980 miles:
"trafficCongestion":"None",
"trafficDataUsed":"None",
"travelDistance":980.715076,
"travelDuration":56038,
"travelDurationTraffic":57776,
"travelMode":"Truck"
For this route, there should be 130 miles in Arizona, and 550 miles in New Mexico, and 300 for Colorado (+/- 40ish miles here or there depending on engine and settings).
Haven't seen that before. I've sent this thread to the engineering team to investigate. I also can't figure out for the life of me what those units are. Will update this post with any updates I hear.
Update
That team recently noticed this issue as well and are investigating a fix. They plan to have this fixed in production by end of next week.
Update 2
The Bing Maps team also asks that you direct technical support related questions to the Microsoft Q&A forums. The StackOverflow community often closes this type of questions as it's not meant to be a support channel. Here is the main technical forum for Microsoft enterprise mapping products: https://learn.microsoft.com/en-us/answers/topics/azure-maps.html

How to get heading accuracy of mobile devices?

I offer a service which needs the correct location and heading of the mobile device the user is accessing my service with. It was relatively easy to get the information but now I am stuck at finding out how accurate the heading I received is.
Since I'm not using any framework for this or develop in Android/iOS, where there are solutions for that problem, I'd need a solution only depending on javascript (+ 3rd party libraries).
I've found the Generic Sensor API from W3C but couldn't find any sensor which hold that information. Neither the Accelerometer-, nor the AbsoluteOrientationSensor held the needed information.
My current code looks like that..
let accelerometer = null;
try {
accelerometer = new Accelerometer({ frequency: 60 });
accelerometer.addEventListener('error', event => {
// Handle runtime errors.
if (event.error.name === 'NotAllowedError') {
console.log('Permission to access sensor was denied.');
} else if (event.error.name === 'NotReadableError') {
console.log('Cannot connect to the sensor.');
}
});
accelerometer.addEventListener('reading', (event) => {
console.log(accelerometer);
console.log(event);
});
accelerometer.start();
.. but since the problem if more of a 'finding the right tool to do the job'-type, it won't help much in better depicting my problems. Further, Google uses kind of the same functionality I'm aiming for in Google Maps, so theoretically there must be a way to get the heading accuracy.
So, in conclusion, is there any way to retrieve the heading accuracy in a simple javascript environment?
Thanks!

What metadata keys are available in Everyplay?

On the Everyplay Unity3D guide page these three lines are given as an example of using metadata with Everyplay.
Everyplay.SharedInstance.SetMetadata("level", levelNumber);
Everyplay.SharedInstance.SetMetadata("level_name", levelName);
Everyplay.SharedInstance.SetMetadata("score", score)
Are there any other metadata keys available than those three? Can you define your own metadata for your game instead of just using predefined keys? Could not find any more documentation on this than the above mentioned example.
You can and should provide as much metadata about the video as you can as there are several features to use the data already under work. The metadata supplied with the video has several intended (future) purposes. Currently only score and level_name are displayed with the videos on Everyplay (for example: http://everyplay.com/videos/8106 ).
The developer can (in the near future) configure what metadata to show with the videos, a racing game could show time, circuit and laps and an FPS game might show kills and deaths. Also we are already developing features into our API to allow developers to use the metadata to query existing videos, for example fetching a list of videos from level 1 in the past 10 days sorted by "score" and so on.
For a quick example here is the metadata that stair dismount (the video in the link above) provided with the same video:
metadata: {
somersaults: 1,
level: 60,
decapitation: false,
bifurcation: false,
push_force_z: -3957.182,
push_force_y: 1773.326,
distance: -1,
push_pos_z: 8.371746,
push_force_x: -1675.732,
push_pos_y: 24.18944,
push_body_name: "LeftForearm",
ragdoll_custom_face: true,
push_pos_x: -0.6025434,
push_body_id: 2189472344,
leaderboard_id: 1208019,
score: 3802645,
level_name: "Revolting Doors",
ragdoll_breakability: false,
distance_leaderboard_id: 0,
ragdoll_name: "Mr. Dismount",
ragdoll: 0
}

Is there any audio ads for iPhone audio apps?

my app is like podcast for web articles. https://apps.apple.com/app/id1273954643
I plan to make a free version and am curious if there is audio ads for iPhone apps.
Since most users of my app don't see the screen, banner ads doesn't fit well.
I want to insert audio ads like spotify.
I checked http://www.medialets.com/ and http://www.greystripe.com/, but their show cases
are quite vague. I sent emails to them, but no reply yet.
Any help will be greatly appreciated.
Thanks!
Hmmm... this seems like an awesome business opportunity that hasn't been properly executed yet.
I have also seen mentions of audio ads being served up into client iPhone apps by TargetSpot.
I really like your idea.And after searching for a while i came across this helpful tutorial-
Though its kind of commercial but hope it will help you.
http://advertising.about.com/od/smallbusinesscampaigns/a/podcastweb.htm
if you're willing to use an API. You could use something like this
https://docs.api.audio/recipes/programmatic-audio-ads
#Check that you are using python 3.8 or further
#pip install -U aflr
import aflr
aflr.api_key = "APIKEY"
audience = [
{"number": "33", "location": "Buckingham"},
{"number": "22", "location": "Sunshine"},
]
text = """
<<soundSegment::effect1>>
<<sectionName::hello>>
If you have any plans for today, cancel them!
<<soundSegment::intro>>
<<sectionName::hello2>>
This really is the final call for {{location}} Hyundai's massive clear out sale! Only until midnight tonight, so come on down!
<<soundSegment::main>>
<<sectionName::main>>
We're clearing out all remaining 2020 Hyundais at Ottawa's top volume Hyundai dealers. These are the last days for clear out pricing and amazing clear out incentives. Zero percent financing for up to 84 months, and up to 7700 in cash price adjustments on all 2020 Hyundais at Hyundai on {{location}}. Pick one of the {{number}} Santa Fays in stock, a family-sized SUV with all-wheel drive and back-up cameras from just $85 weekly, zero down!
It's the easiest time to get into a new Hyundai, but these deals won't be around for long, ONLY until midnight TONIGHT!
<<soundSegment::outro>>
<<sectionName::outro>>
Get into a new Hyundai today. At {{location}} Hyundai, better cars for passionate car drivers. <break time="1s"/>
"""
script = aflr.Script().create(scriptText=text, scriptName="helloworld", moduleName="hello", projectName="hello")
print(script)
for item in audience:
r = aflr.Speech().create(
scriptId=script.get("scriptId"),
voice="en-US-GuyNeural",
speed=120,
silence_padding=0,
audience=[item],
)
print(r)
template = "hotwheels"
print(template)
for item in audience:
r = aflr.Mastering().create(
scriptId=script.get("scriptId"), soundTemplate=template, audience=[item]
)
print(r)
url = aflr.Mastering().download(
scriptId=script.get("scriptId"),
parameters=item,
destination=".",
)
print(f"✨ Mastered file for template {template} ✨")
print(url)
```
That way you could serve this, this is in python. You could also do it in Swift (but there's no sdk for this atm you'd need to write it yourself).
Disclamier - I work for www.api.audio

sencha touch :: how to handle long lists on iOS

in my sencha touch app I need to display a list of over 600 entries of objects per selected customer.
imagine one store holds some customers, displayed in a list. each of them has some "has-many"-related sub-stores, one holding about 600 objects (with urls, title, description...). these sub-info has to be listed when you select one customer from the first list.
the problem is on iOS you have to wait some seconds before the list is shown and it is very slow to scroll/use. it seems that it slows down the whole app.
are there any other options to display long lists, maybe like pagination ore something...
thnx!
edit: I found this article and will test these thoughts soon: Link
edit2: here we go: https://github.com/Lioarlan/UxBufList-Sench-Touch-Extension
You can paginate your list by adding a pageSize param to your store and the listpaging plugin to your list. By setting the autoPaging option, you can control whether the data is loaded automatically or on user click. Below is an example:
// store
Ext.regStore('BarginsStore', {
model: 'BarginModel',
autoLoad: true,
pageSize: 6,
clearOnPageLoad: false,
sorters: 'category',
getGroupString: function(record) {
return record.get('category');
}
});
// list
this.list = new Ext.List({
store: 'BarginsStore',
plugins: [{
ptype: 'listpaging',
autoPaging: true
}],
singleSelection: true,
emptyText: '<p class="no-bargins">No bargins found matching this criteria.</p>',
itemTpl: '<div class="bargin-record">{name}</div>'
});
are there any other options to display long lists, maybe like pagination ore something...
Pagination. Smartphones have far more limited CPU and RAM resources than a desktop PC. A six hundred row table with several elements is not going to display well on the devices on the market now. Hell, it'll probably slow down desktop browsers. Paginate it.