## group by – Efficient way to get data for each date range intervals using single query | MongoDB

Sorry if I misunderstood or asked a duplicate question!

I have collections about products and purchases. I need to get statistics for each time interval.
I need following:

Name quantity (date 1 range) quantity (date 2 range)
Name One 500 400
Name Two 251 450
Name Three 444 600

I have following collections:

``````//Products
{
name: {
type: String,
required: (true, "The prodcut name is required"),
unique: true,
}
price: {
type: mongoose.Types.Decimal128,
default: "0.0",
},
}

//Orders model scheme
{
product: {
type: Schema.Types.ObjectId, ref: "Products",
},
price: {
type: mongoose.Types.Decimal128,
default: "0.0",
},
quantity: {
type: Number,
default: 0,
},
orderDate: {
type: Date,
default: Date.now, //new Date(),
},
}
``````

And I have the following aggregate function:

``````    OrdersModel.aggregate(
(
{ \$match: { orderDate: { \$gte: new Date( sdt ), \$lte: new Date( edt  ) } } },
{
\$group:
{
_id: "\$product_name", //{ name: "\$name"},
totalQuantity: { \$sum: "\$quantity" },
}
},
{
\$project: {
_id: 1,
qty: "\$totalQuantity",
//...
}
}
)
)
``````

This query is working, but only for one time interval. But I need to get results for some time interval.
But I need to get results for more than one date range interval. I’m new to NoSQL, I’ve tried retrieving data from one or more-time intervals but couldn’t find it. How can I solve this problem? That is, I need to get the sales total Quantity of a product at different time intervals.

``````2010-01-01 to 2012-01-01
2015-01-01 to 2017-01-01
...
``````

Time intervals can be dynamic. There can be a minimum of 1 and a maximum of 4 time intervals.

## general topology – How come every compact connected surface admits a presentation in which all vertices are identified with a single point?

I’ve been stuck for a while now on this step of the classification theorem proof in Introduction to Topological Manifolds by John Lee:

STEP 4: M admits a presentation in which all vertices are identified to a single
point.

Where M is a connected compact surface.

I don’t understand how could this be true. Take a (bounded) cylinder for example. It has the following presentation: $$aba^{-1}c$$. I don’t see how all vertices could be mapped to the same point, that could only happen if we turn it into a torus (i.e. identify b and c together). The key step in the above proof seems to be that he’s assuming that for every edge $$b$$ there is another edge $$b$$ or $$b^{-1}$$ with which it is identified; but again: that’s not true in the case of the cylinder, not all edges are identified. The same problem happens if we consider the presentation of a mobius band for example and other surfaces as well. I’ve rechecked the definitions several times to see if I was missing something basic but I’m not able to see where I went wrong so I would appreciate any help on this.

## woocommerce offtopic – Add class to h1 title on single product page using filter

I’m looking at my Single Product title template:

``````the_title( '<h1 class="product_title entry-title">', '</h1>' );
``````

And I want to add a class (‘small’) to the title without modifying the template (to avoid problems with future updates).

I’d like to plop in a filter but don’t know how to do this. I suspect it’s something like this:

``````  add_filter( 'woocommerce_product_loop_title_classes', 'custom_woocommerce_product_title_classes' );

function custom_woocommerce_product_title_classes( \$class ) {
return \$class . ' small';
}
``````

Which seems to work for the shop page, but not the single product page.

## functions – query_vars treat as single var from URL

I want to use the link parameter from URL as one query_var.
If I visit the page where (flipwoo) is in, for example:
`https://test.com/test/?link=https://test.com/?download_file=1953&order=wc_order_zHOH4RI97k9mR&email=test%40gmail.com&key=91c44b50-6922-4976-ac57-6d499136eead`
the following is echoed:
`https://test.com/?download_file=1953`
but I want the whole URL after ?link= to be echoed:
`https://test.com/?download_file=1953&order=wc_order_zHOH4RI97k9mR&email=test%40gmail.com&key=91c44b50-6922-4976-ac57-6d499136eead`

Where is the mistake?

``````function themeslug_query_vars( \$qvars ) {
return \$qvars;
}

}

``````

## 8 – How can I render single Simplenews fields in Twig?

I had a Drupal 7 site and I have build my newsletter with print render. Example:

`````` print render(\$build('field_title'));
print render(\$build('field_image'));
print render(\$build('field_description));
``````

With that, I could render every field, one per one. Now, how can I do that with Drupal 8 and twig?

What I want is to build a newsletter with layout and existing content but without the generic `{{ build }}`.

I successfully print every field of the node with tokens like `(node:body)`, but I can’t print the rest of the node and only `{{ build }}` can do it.
I know this is not correct, but can I do something like that `{{ build | description }}`?

I use the Simplenews template.

## simplifying expressions – How to express sum of rational functions as a single term

I have rational functions $$dfrac{q_1(x)}{p_1(x)},ldots,dfrac{q_n(x)}{p_n(x)}$$ whose numerator I am trying to compute.

I want mathematica to take the lcm of $$p_1(x),ldots,p_n(x)$$ and express the sum

$$dfrac{q_1(x)}{p_1(x)}+ldots+dfrac{q_n(x)}{p_n(x)}$$ as a single rational expression with polynomials $$dfrac{q(x)}{p(x)}$$ such that $$p(x)$$ is the lcm of $$p_i(x)$$. The thing is these rational functions are quite ugly and their denominators do not share a many factors (at most 1 with another rational term in the sum).

I think because of this, expand, simplify and fullsimplify are not working as I envisioned them to work.

My main interest here are the coefficients of $$p(x)$$ in the resulting sum. How can I compute this? I appreciate your time spent on this.

## air travel – Can I bring a single shot of live ammunition onto the plane from US to UK as a souvenir?

Can I bring a single shot of live ammo onto the plane from US to UK as a souvenir?

as being seen by security authorities as looking something like

Can I bring a single shot informal firearm onto an aircraft if I also carry the single live ammunition round with me but separately from the firearm ?

Seen in this light, without knowing the specific regulations it’s obvious (or should be 🙂 ) that the answer is probably “NO!!!”, or at very best “Only after very large amounts of questions and paperwork, probably not as carry on, probably not without significant pre-application period and, probably, no!”

If you have Facebook access then this page will be informative Bootleg Gunz – The Bazaar of Bizarre Guns will be informative re what can be achieved.

Genuine: 22 LR, Australia

A “bootleg” / ‘slam-fire’ / … firearm can be implemented in many ways from equipment and material that does not resemble a conventional firearm. The common key component to any such weapon is a live round – if you have that the weapon proper is doable.

Bearing in mind also that if you are able to carry such a round onto an aircraft then Bob & Carol & Ted & Alice (and Uncle Tom Cobbly and all) also can and a number of you can then pass your ammunition to someone who has a/the weapon.

## \$ 1,129,145,280 Moved Through A Single Transaction Over ETH Network

Veteran Ethereum developer Kain Warwick, founder of the high-level decentralized financial protocol Synthetix Network, announced possibly the biggest transaction of the day on Ethereum.
Details of the transaction have been viewed by leading ETH web browser Etherscan. According to the information, 74,580,269 SNX or a transfer of \$ 1,129,145,279 was included in Ethereum’s block 11657482.

## How many times a single transaction can be included into different blocks?

I would like to know is there a limit after which a miner cannot include a transaction into his block.

## long exposure – Will stacked ND filters perform as well as a single 10 stop ND filter?

If you’re stacking filters, you’re liable to get vignetting around the corners of the photo. Plus, there’s the danger of internal reflections, and other optical issues.

My preferred solution is a single, variable ND filter, with which you can dial-in the amount of light you want.

EDIT responding to comment:

A variable ND filter is one that can vary its density. By twisting it, it gets lighter or darker, so — depending on the filter in question — you could adjust from, say, 1 stop to 10 stops, all in a single accessory. Obviously this is more expensive, even than buying a couple of regular filters, but I find it a big help.

As I understand it, this is basically built of two thin CPL filters, so twisting it alters the angles between the polarization, letting in more or less light. But when I tried to do that myself, with two of my own CPLs, the results just didn’t work at all.

EDIT 2: I only just looked at your sample image. I don’t think that you can do this photo with ND filters alone. I’m pretty sure there’s also multi-exposure HDR going on in there as well.