So I have this MongoDB data source. I used the interface to create a trend visualization and it works.
But I have a native code that needs to be used because the interface isn't good enough. It seems that the Trend visualization is disabled
Here is the full query
[
{
"$match": {
"$expr": {
"$lt": [
"$created",
{
"$dateFromString": {
"dateString": "2023-01-01T00:00Z"
}
}
]
}
}
},
{
"$addFields": {
"activityCount": {
"$cond": {
"if": {
"$and": [
{
"$isArray": "$divisions"
},
{
"$gt": [
{
"$size": "$divisions"
},
0
]
}
]
},
"then": {
"$size": "$divisions"
},
"else": 1
}
}
}
},
{
"$match": {
"document_status": "final"
}
},
{
"$project": {
"created": 1,
"divisions": 1,
"activityCount": 1
}
},
{
"$group": {
"_id": {
"year": {
"$let": {
"vars": {
"parts": {
"$dateToParts": {
"timezone": "GMT",
"date": "$created"
}
}
},
"in": {
"$dateFromParts": {
"timezone": "GMT",
"year": "$$parts.year"
}
}
}
}
},
"count": {
"$sum": "$activityCount"
}
}
},
{
"$sort": {
"_id": 1
}
},
{
"$set": {
"year": "$_id.year"
}
},
{
"$unset": [
"_id"
]
},
{
"$setWindowFields": {
"sortBy": {
"year": 1
},
"output": {
"cumulative": {
"$sum": "$count",
"window": {
"documents": [
"unbounded",
"current"
]
}
}
}
}
},
{
"$project": {
"cumulative": 1,
"year": 1
}
}
]
Here is the data from Admin > Troubleshooting
{
"browser-info": {
"language": "en-US",
"platform": "Linux x86_64",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
"vendor": "Google Inc."
},
"system-info": {
"file.encoding": "UTF-8",
"java.runtime.name": "OpenJDK Runtime Environment",
"java.runtime.version": "11.0.17+8",
"java.vendor": "Eclipse Adoptium",
"java.vendor.url": "https://adoptium.net/",
"java.version": "11.0.17",
"java.vm.name": "OpenJDK 64-Bit Server VM",
"java.vm.version": "11.0.17+8",
"os.name": "Linux",
"os.version": "5.15.0-58-generic",
"user.language": "en",
"user.timezone": "GMT"
},
"metabase-info": {
"databases": [
"h2",
"mongo",
"postgres"
],
"hosting-env": "unknown",
"application-database": "mysql",
"application-database-details": {
"database": {
"name": "MariaDB",
"version": "10.10.2-MariaDB-1:10.10.2+maria~ubu2204"
},
"jdbc-driver": {
"name": "MariaDB Connector/J",
"version": "2.7.6"
}
},
"run-mode": "prod",
"version": {
"date": "2023-01-17",
"tag": "v0.45.2",
"branch": "release-x.45.x",
"hash": "819ce29"
},
"settings": {
"report-timezone": "Asia/Jakarta"
}
}
}