Price inside items object is not correct - google-analytics-4

I'm just switching from Universal-Analytic to Analytic 4 and I want to track the product detail view by using "view_item" event by using this code. The correct price is 605.
gtag("event", "view_item", {
currency: "JPY",
value: {{ product_price }},
items: [
{
item_id: "{{ Product.jan }}",
item_name: "{{ Product.name }}",
currency: "JPY",
price: {{ product_price }},
}
]
});
Everything is working fine except the "price" property inside the "items" object. it add 6 zero (000000) to my price
Please check the debug view screenshot for more detail
Could you please tell me what's wrong with my code? Thanks for your help!!!!

Related

MongoDB Union All?

I am trying to union 3 collections in one but can't make it work (same as union all). As an example, I have 3 collections:
1:active users
[{_id:'', client_id:'',created:''}]
2:not active users
[{_id:'', visitor_id:'',created:''}]
3:blocked users
[{_id:'', blocked_id:'',created:''}]
what i am trying to do is to combine all 3 collections in one, sort them by date and make sure i get the first 10 results, something like that:
[{_id:'', client_id:'',created:''},
{_id:'', blocked_id:'',created:''},
{_id:'', visitor_id:'',created:''}]
I came up with this code:
collection('active).aggregate([
{
"$facet":{
"active":[
{"$match":{ "client_id": 5cfe83820c19ee3c50c8f323 }}
],
"not_active":[
{"$match":{"cust_id":"5cfe83820c19ee3c50c8f323" }}
],
"blocked":[
{"$match":{"blocked_id":"5cfe83820c19ee3c50c8f323" }}
]
}
},
{
"$skip":0
},
{
"$limit":10
},
{
"$sort":{
"created":-1
}
}
])
but this code return empty array:
[ { active: [], not_active: [], blocked : []} ]
What i am doing wrong?
Thanks
Finally i came up with this code that does the job:
mongo.clients.aggregate([
{$limit:1},{$project:{_id:1}},{$project:{_id:0}},
{$lookup : {from:'active',as:'active',pipeline:[{$match:{}}]}},
{$lookup : {from:'not_active',as:'not_active',pipeline:[{$match:{}}]}},
{$lookup : {from:'blocked',as:'blocked',pipeline:[{$match:{}}]}},
{$project:{Union:{$concatArrays:['$active','$not_active','$blocked']}}},
{$unwind:"$Union"},
{$replaceRoot:{newRoot:"$Union"}},
{$skip:0},
{$limit:10},
{$sort:{'created': -1}}
]).then(x);
Here is more detailed answer:
enter link description here

Why grouping creates 2 different groups for same field value?

I use OData direct binding to XML view:
<List items="{path:'Items', sorter : {path : 'group', group : true}}">
...
</List>
The 'Items' content, bottom line, looks like follows:
[{
group: "1",
value: "a"
},{
group: "1",
value: "b"
},{
group: "2",
value: "c"
},{
group: "2",
value: "d"
},{
group: "1",
value: "e"
}]
Strangely, I see 3 groups in my list: group "1" with 2 elements, group "2" with 2 elements and again group "1" with one last element.
What do I miss?
Thank you.
It is a duplication of the SAPUI5 - Group list items without sorting ascending or descending
You have missed groupHeaderFactory, I have made the changes as per the requirement.
View
<List headerText="Products"
items="{
path: '/items',
sorter: {
path: 'group',
descending: false,
group: true
},
groupHeaderFactory: '.getGroupHeader'
}">
Controller
getGroupHeader: function (oGroup){
return new sap.m.GroupHeaderListItem({
title: oGroup.key,
upperCase: false
});
},

How to update multiple elements of a single array in mongoDB

I have a document of mongoDb like following
{
_id: "c4bYJWz42T2JzbmHh",
DATA:[
{sno:1, name: xyz, country: xyz},
{sno:2, name: xyz1, country: xyz1},
{sno:3, name: xyz2, country: xyz2}
]
}
Now i want to update name and country on basis of 'sno'.I have used this approach
ExampleDb.update({
_id: data.id
}, {
$set: {
"DATA.$[elem].name": data.name ,
"DATA.$[elem].country" :data.country
}
},
{
arrayFilters: [ { "elem.sno": data.sno } ]
});
ut seems worng as it show following error.
Exception while invoking method 'ExampleDb.update' MongoError: Modifiers operate on fields but we found a Array instead.

How can I search two columns (one of which only appears in a few records)?

I am performing a search on the following 2 columns of a document: name and displayName. However, only a few records have displayName column. When a record has both, I want to search both fields (name and displayName) for the possible match. Otherwise, if the record doesn't have the column displayName, I just want to search name instead. So I thought I'd do an OR. This however will only search fields that have both columns - although I want to search all records.
How can I update the query to achieve the above? Here's what I tried:
function search(search) {
return this.find({ $or: [
{"displayName" : {"$regex" : ".*"+ search +".*", "$options": "-i"}},
{"name" : {"$regex" : ".*"+ search +".*", "$options": "-i"}}
]}).exec();
}
So on the query above, the logic tells me that if displayName column doesn't exist, the first check will return false so it will then search name which will return true/false based on the match. I am obviously missing something here because even if the second check would be true, the overall result comes out false (which is more like AND behavior instead of OR).
Data Example:
{ id: 3, name: "John Steinbeck", displayName: "Steinbeck" }
{ id: 4, name: "John Lennon" }
{ id: 5, name: "Doe", displayName: "John" }
{ id: 5, name: "Harry Potter", displayName: "Harry" }
Search word:
john
Expected Result:
{ id: 3, name: "John Steinbeck", displayName: "Steinbeck" }
{ id: 4, name: "John Lennon" }
{ id: 5, name: "Doe", displayName: "John" }
Later Edit
This query does seem to work after all, the problem turned out to be the data and not the query. Human error. My apologies :)
change your query:
db.getCollection('user').find({ $or: [
{"name" : {$regex: "john", $options: "$i"}},
{"displayName" : {$regex: "john", $options: "$i"}}]})
You've to different conditions:
Both field exist and have the correct value
Only name exist and have the correct value
use $exist and $or!
for example:
db.col.find({ $or: [ { name: {$regex : ".*John.*"}}, displayName: {$regex : ".*Steinbeck.*"}}, { name: "john", { displayName: { $exists: false } } } ] } )

Mongodb, concat more updates in one query

There is a way to concat more updates?
For example I would like to change more values in the same element. So having this...
{
cc: [
{ user_id: "1", hasSeen:true}
,{ user_id: "2", hasSeen:false}
,{ user_id: "3", hasSeen:false}
]
,conversation: [{
user_id: "1",
text: "message by 1, to 2and3"
}]
}
...I would like to push a new conversation object and also change all the hasSeen values.
For do the first point, no problem, I just push only a new conversation object. And it works...
...update(
{ _id : _param.conversation_id }
,{ $push:{ conversation:{user_id:"2",text:"message by 2, to 1,3"} }}
)
.exec(function(err, numAffected, rawResponse) {
});
But I would like also to change the three "hasSeen" values in the same time. is it possible?
Can I do it with one query? or i should split it in two queries?
ps: I use mongoose.
Currently the positional operator (which I think you will need here) does not work in such a manner that you can do a type of conditional update whereby you iterate through a list of $incs or $sets to change those subdocument values.
There is a JIRA for such a thing that could possibly help you: https://jira.mongodb.org/browse/SERVER-6566?page=com.atlassian.jira.plugin.system.issuetabpanels:changehistory-tabpanel but it is filed under "features we are not sure of".
Best to split this up currently.