Mongoose – Aggregation – Setar campo como valor

Não estou conseguindo fazer a query abaixo me retornar alguns campos como valores de outros campos

Ex.:

{  _id:'Javascript',  valorWd: valorPs_Label // wd = "based on" e ps_Label = "ecmascript"  }  Linguagem.aggregate(         [          //{$  match: {"isIdentifier": "false"}},         {"$  match": {             "linguagemLabel": "JavaScript"}         },         {"$  group": {              _id: "$  linguagemLabel",              wd: {$  addToSet: "$  wdLabel"},              ps: {$  addToSet: "$  ps_Label"},              wdpq: {$  addToSet: "$  wdpqLabel"},              pq: {$  addToSet: "$  pq_Label"},             }         },             {"$  project": {                 wd: 1,                 ps: 1,                 wdpq: 1,                 pq: 1,                 prop: 1               }         },         { $  sort : { _id : 1} }     ]).exec(function(err, ret){         if(err){console.log(err)}         console.log(ret)         return res.json(ret);     }); 

Mongo aggregation on array values

I have a mongo document like this:

{  "_id":"5cfe7767f4046327ad57ec33",  "area":"Actor",   "profile":{    "about":true,     "gallery":true,    "characteristics":[      "Gender": true,      "Height": false,      "Weight": false    ]  } } 

And another one like this:

{  "_id":"5cfe7767f4046327ad57ec33",  "characteristic":"Gender",   "items":["Female","Male"] } 

I want to aggregate the characteristics from the first document that are true with the values of the other document. Something like this:

{  "_id":"5cfe7767f4046327ad57ec33",  "area":"Actor",   "profile":{    "about":true,     "gallery":true,    "characteristics:[      "Gender": ["Female","Male"],      "Height": false,      "Weight": false    ]  } } 

Is it possible?

Views Aggregation problem in Drupal 8

I have created a view of node content and I need author name, role, and image to show with content. I have also made a relationship with the user in the advance section for the above-mentioned fields. it’s working correctly but when I on Aggregation it gives this SQL query error.

SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘users_field_data_node_field_revision__user__user_picture.user_picture_’ in ‘field list’: SELECT node_field_data.title AS node_field_data_title, users_field_data_node_field_revision.name AS users_field_data_node_field_revision_name, users_field_data_node_field_revision__user__user_picture.user_picture_ AS users_field_data_node_field_revision__user__user_picture_use, nodeviewcount.id AS id, nodeviewcount.nid AS nodeviewcount_nid, node_field_data.created AS node_field_data_created, MIN(node_field_data.nid) AS nid, MIN(users_field_data_node_field_revision.uid) AS users_field_data_node_field_revision_uid FROM {node_field_data} node_field_data INNER JOIN {node_field_revision} node_field_revision ON node_field_data.vid = node_field_revision.vid LEFT JOIN {users_field_data} users_field_data_node_field_revision ON node_field_revision.uid = users_field_data_node_field_revision.uid LEFT JOIN {user__user_picture} users_field_data_node_field_revision__user__user_picture ON users_field_data_node_field_revision.uid = users_field_data_node_field_revision__user__user_picture.entity_id AND (users_field_data_node_field_revision__user__user_picture.deleted = :views_join_condition_0 AND users_field_data_node_field_revision__user__user_picture.langcode = users_field_data_node_field_revision.langcode) LEFT JOIN {nodeviewcount} nodeviewcount ON node_field_data.nid = nodeviewcount.nid WHERE (node_field_data.status = :db_condition_placeholder_2) AND (node_field_data.type IN (:db_condition_placeholder_3)) GROUP BY node_field_data_title, users_field_data_node_field_revision_name, users_field_data_node_field_revision__user__user_picture_use, id, nodeviewcount_nid, node_field_data_created ORDER BY node_field_data_created DESC LIMIT 11 OFFSET 0; Array ( [:db_condition_placeholder_2] => 1 [:db_condition_placeholder_3] => ask_question [:views_join_condition_0] => 0 )

I don’t know what is the issue and how to fix this problem. Aggregation is must for me in this view because I have to count Node ID through Aggregation.

Taxonomy terms not localized in view with enabled aggregation

On a view on content, I added a field “All taxonomy terms” (Display all taxonomy terms associated with a node from specified vocabularies) and enabled aggregation, see screenshot of view attached. This view is listing exclusively terms that are actually used in content. While the view is working for the standard language of the site, the terms are not translated into the other languages despite the vocabulary is translatable. Once I disable the aggregation, the translation of terms is working again.

So how can I make the translation of terms work?

enter image description here

Kubernetes aggregation certificates – apiserver client authentication allowed names

Definitions I’m using in this question:

  • Main apiserver: the core kube-apiserver
  • Extension apiserver: an addon like metrics-server

I am reading through the configure aggregation layer guide and I don’t understand the main apiserver’s use of --requestheader-allowed-names. In section Kubernetes Apiserver Client Authentication it says:

The connection must be made using a client certificate whose CN is one of those listed in –requestheader-allowed-names. Note: You can set this option to blank as –requestheader-allowed-names=””. This will indicate to an extension apiserver that any CN is acceptable.

It makes it sound like the main apiserver is responsible for setting this. Surely the extension apiserver would be in control of this and determine what is acceptable? Why configure this on the main apiserver at all? I.e. The client certificate common names are what they are and it’s up to the extension apiserver to accept/reject these?

Or is that doc section mixing options that are passed to both the main and extension apiservers?

Views Table with Aggregation, total values counted per option

I’m setting up a view of event registrations. Each registration will be allocated to 1 of 3 workshops at two different times in the day.

I’m looking to output the total number of allocations per workshop so we can try to balance the delegate numbers.

I’m pretty close, but not quite there.

I’m using the Display Format of Table with aggregation options with “Group and Compress” on the Event ID.

I then apply the group function on two data fields: “Allocated Workshop AM” and “Allocated Workshop PM”.

I can get closest to my desired result using the “Tally members” option, however, the results are wrong.

enter image description here

They are showing much lower numbers than are actually allocated.

enter image description here

Any suggestions on how I could achieve this?

How to disable core JS aggregation and AdvAgg just for admin paths

I help look after a site which uses $ settings['file_public_base_url'] to serve files from a different subdomain on the frontend, but on the backend (admin paths like node/add and node/edit) this causes our JS to be loaded with absolute rather than relative URLs which seems to cause an issue with JS loaded via AJAX not executing correctly. There are no JS errors in my devtools console, but I suspect the cause is that the JS is being loaded from differing subdomains, as turning AdvAgg and core’s JS aggregation off makes the JS files load via relative paths and function as intended.

Without any errors showing in my console or server logs I’m not sure I’m going to be able to get to the bottom of the AJAX issue, so for now a compromise seems to be to turn off aggregation for admin and content editing routes.

What would be the best way to do that? I know I can set $ config['system.performance']['js']['preprocess'] = FALSE; and presumably a similar config key for AdvAgg’s own setting (we have AdvAgg set to optimise/compress JS, so even with system.performance.js.preprocess turned off AdvAgg will still manage the files and use absolute paths to include them. Can config settings be altered on a per route/path basis?

Pandas Groupby Conditional Aggregation

Let’s say you have a dataframe as follows:

data = pd.DataFrame({'Year': [2019]*5+[2020]*5,           'Month': [1,1,2,2,3]*2,           'Hour': [0,1,2,3,4]*2,           'Value': [0.2,0.3,0.2,0.1,0.4,0.3,0.2,0.5,0.1,0.2]}) 

Then, set “low” times to be hours between 1 and 3 (inclusive), and “high” times to be all other hours (in this case, hours 0 and 4). What I would like to do is get the average Value for the “low” and “high” times for each Year and Month.

For loops work, but they’re not ideal. I could also create a dummy variable (for instance, 0s and 1s) to signify the “low” and “high” times in the dataframe to groupby. However, it seems to me that there should be some way to use Pandas groupby([‘Year’, ‘Month’]).agg(…) to achieve the result in an efficient/optimal way. I haven’t had any luck thus far using groupby+agg, mainly because agg() uses only a series (not the remaining dataframe), so one can’t use a conditional within agg based on the Hour to calculate the average Value.

Any help is appreciated 🙂

Sum up views custom text field using aggregation

Would it be possible to set the custom text field value in views? I have a simple calculation in custom text field. It gives me the correct calculation, but when I’m trying to aggregate the views to calculate the total sum from custom text field it returns 0 value.

I’m thinking that custom text field has no value in the first place and it’s only output an HTML. Would it be possible to set custom text field value from the calculated output? Or is there any other way to achieve this without using the hook system?

Please note that I’m also attaching another view into custom text field which returns a total sum from another field.