diff --git a/src/mothership-app/migrations/1702569081_updated_stats.js b/src/mothership-app/migrations/1702569081_updated_stats.js
new file mode 100644
index 00000000..67107ad7
--- /dev/null
+++ b/src/mothership-app/migrations/1702569081_updated_stats.js
@@ -0,0 +1,419 @@
+///
+migrate((db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("buq519uv711078p")
+
+ collection.options = {
+ "query": "SELECT\n (ROW_NUMBER() OVER()) as id,\n COUNT(DISTINCT users.id) AS total_users,\n COUNT(DISTINCT CASE WHEN users.subscription ='legacy' THEN users.id END) AS total_legacy_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription ='free' THEN users.id END) AS total_free_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'premium' THEN users.id END) AS total_pro_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'lifetime' THEN users.id END) AS total_lifetime_subscribers,\n COUNT(DISTINCT instances.id ) AS instances,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-1 hour') THEN instances.id END) AS instances_last_hour,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-24 hours') THEN instances.id END) AS instances_last_24_hours,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-7 days') THEN instances.id END) AS instances_last_7_days,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-30 days') THEN instances.id END) AS instances_last_30_days\nFROM\n verified_users users\nLEFT JOIN\n instances ON users.id = instances.uid;\n"
+ }
+
+ // remove
+ collection.schema.removeField("gbusypds")
+
+ // remove
+ collection.schema.removeField("enlkpkjb")
+
+ // remove
+ collection.schema.removeField("uouawo7o")
+
+ // remove
+ collection.schema.removeField("rb1wzsv7")
+
+ // remove
+ collection.schema.removeField("whdajjy5")
+
+ // remove
+ collection.schema.removeField("xwxkyd41")
+
+ // remove
+ collection.schema.removeField("uyczm2an")
+
+ // remove
+ collection.schema.removeField("jsgangu8")
+
+ // remove
+ collection.schema.removeField("0dalcs71")
+
+ // remove
+ collection.schema.removeField("jzzbzyxy")
+
+ // remove
+ collection.schema.removeField("zj0otefi")
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "gptgmwlu",
+ "name": "total_users",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "u6uelwdv",
+ "name": "total_legacy_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "aukds5ub",
+ "name": "total_free_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "8macz0ll",
+ "name": "total_pro_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "61tap13r",
+ "name": "total_lifetime_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "q5r9xzdu",
+ "name": "instances",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "dtknpqjw",
+ "name": "instances_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "afbuvawa",
+ "name": "instances_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "clggyuqh",
+ "name": "instances_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "q5tv92td",
+ "name": "instances_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ return dao.saveCollection(collection)
+}, (db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("buq519uv711078p")
+
+ collection.options = {
+ "query": "SELECT\n (ROW_NUMBER() OVER()) as id,\n COUNT(DISTINCT users.id) AS total_users,\n COUNT(DISTINCT CASE WHEN users.verified = 1 THEN users.id END) AS total_verified_users,\n COUNT(DISTINCT CASE WHEN users.subscription ='legacy' THEN users.id END) AS total_legacy_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription ='free' THEN users.id END) AS total_free_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'premium' THEN users.id END) AS total_pro_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'lifetime' THEN users.id END) AS total_lifetime_subscribers,\n COUNT(DISTINCT CASE WHEN users.verified = 1 THEN instances.id END) AS verified_instances,\n COUNT(DISTINCT CASE WHEN users.verified = 1 AND instances.updated > DATETIME('now', '-1 hour') THEN instances.id END) AS verified_instances_last_hour,\n COUNT(DISTINCT CASE WHEN users.verified = 1 AND instances.updated > DATETIME('now', '-24 hours') THEN instances.id END) AS verified_instances_last_24_hours,\n COUNT(DISTINCT CASE WHEN users.verified = 1 AND instances.updated > DATETIME('now', '-7 days') THEN instances.id END) AS verified_instances_last_7_days,\n COUNT(DISTINCT CASE WHEN users.verified = 1 AND instances.updated > DATETIME('now', '-30 days') THEN instances.id END) AS verified_instances_last_30_days\nFROM\n users\nLEFT JOIN\n instances ON users.id = instances.uid;\n"
+ }
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "gbusypds",
+ "name": "total_users",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "enlkpkjb",
+ "name": "total_verified_users",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "uouawo7o",
+ "name": "total_legacy_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "rb1wzsv7",
+ "name": "total_free_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "whdajjy5",
+ "name": "total_pro_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "xwxkyd41",
+ "name": "total_lifetime_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "uyczm2an",
+ "name": "verified_instances",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "jsgangu8",
+ "name": "verified_instances_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "0dalcs71",
+ "name": "verified_instances_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "jzzbzyxy",
+ "name": "verified_instances_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "zj0otefi",
+ "name": "verified_instances_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // remove
+ collection.schema.removeField("gptgmwlu")
+
+ // remove
+ collection.schema.removeField("u6uelwdv")
+
+ // remove
+ collection.schema.removeField("aukds5ub")
+
+ // remove
+ collection.schema.removeField("8macz0ll")
+
+ // remove
+ collection.schema.removeField("61tap13r")
+
+ // remove
+ collection.schema.removeField("q5r9xzdu")
+
+ // remove
+ collection.schema.removeField("dtknpqjw")
+
+ // remove
+ collection.schema.removeField("afbuvawa")
+
+ // remove
+ collection.schema.removeField("clggyuqh")
+
+ // remove
+ collection.schema.removeField("q5tv92td")
+
+ return dao.saveCollection(collection)
+})
diff --git a/src/mothership-app/migrations/1702569254_updated_stats.js b/src/mothership-app/migrations/1702569254_updated_stats.js
new file mode 100644
index 00000000..04ac9112
--- /dev/null
+++ b/src/mothership-app/migrations/1702569254_updated_stats.js
@@ -0,0 +1,476 @@
+///
+migrate((db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("buq519uv711078p")
+
+ collection.options = {
+ "query": "SELECT\n (ROW_NUMBER() OVER()) as id,\n COUNT(DISTINCT users.id) AS total_users,\n COUNT(DISTINCT CASE WHEN users.subscription ='legacy' THEN users.id END) AS total_legacy_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription ='free' THEN users.id END) AS total_free_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'premium' THEN users.id END) AS total_pro_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'lifetime' THEN users.id END) AS total_lifetime_subscribers,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-1 hour') THEN users.id END) AS new_users_last_hour,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-24 hours') THEN users.id END) AS new_users_last_24_hours,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-7 days') THEN users.id END) AS new_users_last_7_days,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-30 days') THEN users.id END) AS new_users_last_30_days,\n\n COUNT(DISTINCT instances.id ) AS total_instances,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-1 hour') THEN instances.id END) AS total_instances_last_hour,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-24 hours') THEN instances.id END) AS total_instances_last_24_hours,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-7 days') THEN instances.id END) AS total_instances_last_7_days,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-30 days') THEN instances.id END) AS total_instances_last_30_days\nFROM\n verified_users users\nLEFT JOIN\n instances ON users.id = instances.uid;\n"
+ }
+
+ // remove
+ collection.schema.removeField("gptgmwlu")
+
+ // remove
+ collection.schema.removeField("u6uelwdv")
+
+ // remove
+ collection.schema.removeField("aukds5ub")
+
+ // remove
+ collection.schema.removeField("8macz0ll")
+
+ // remove
+ collection.schema.removeField("61tap13r")
+
+ // remove
+ collection.schema.removeField("q5r9xzdu")
+
+ // remove
+ collection.schema.removeField("dtknpqjw")
+
+ // remove
+ collection.schema.removeField("afbuvawa")
+
+ // remove
+ collection.schema.removeField("clggyuqh")
+
+ // remove
+ collection.schema.removeField("q5tv92td")
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "qxokezck",
+ "name": "total_users",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "nhnu96xj",
+ "name": "total_legacy_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "1ily0n9p",
+ "name": "total_free_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "8yxlysux",
+ "name": "total_pro_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "twfa4xdq",
+ "name": "total_lifetime_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "etzohhgx",
+ "name": "new_users_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "xw6z5two",
+ "name": "new_users_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "3kvrm6bs",
+ "name": "new_users_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "dv5s3tlf",
+ "name": "new_users_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "xi0zsmee",
+ "name": "total_instances",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "tjjqxoin",
+ "name": "total_instances_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "xt3tiocm",
+ "name": "total_instances_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "8eknw7mm",
+ "name": "total_instances_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "nrhmdzra",
+ "name": "total_instances_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ return dao.saveCollection(collection)
+}, (db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("buq519uv711078p")
+
+ collection.options = {
+ "query": "SELECT\n (ROW_NUMBER() OVER()) as id,\n COUNT(DISTINCT users.id) AS total_users,\n COUNT(DISTINCT CASE WHEN users.subscription ='legacy' THEN users.id END) AS total_legacy_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription ='free' THEN users.id END) AS total_free_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'premium' THEN users.id END) AS total_pro_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'lifetime' THEN users.id END) AS total_lifetime_subscribers,\n COUNT(DISTINCT instances.id ) AS instances,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-1 hour') THEN instances.id END) AS instances_last_hour,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-24 hours') THEN instances.id END) AS instances_last_24_hours,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-7 days') THEN instances.id END) AS instances_last_7_days,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-30 days') THEN instances.id END) AS instances_last_30_days\nFROM\n verified_users users\nLEFT JOIN\n instances ON users.id = instances.uid;\n"
+ }
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "gptgmwlu",
+ "name": "total_users",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "u6uelwdv",
+ "name": "total_legacy_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "aukds5ub",
+ "name": "total_free_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "8macz0ll",
+ "name": "total_pro_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "61tap13r",
+ "name": "total_lifetime_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "q5r9xzdu",
+ "name": "instances",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "dtknpqjw",
+ "name": "instances_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "afbuvawa",
+ "name": "instances_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "clggyuqh",
+ "name": "instances_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "q5tv92td",
+ "name": "instances_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // remove
+ collection.schema.removeField("qxokezck")
+
+ // remove
+ collection.schema.removeField("nhnu96xj")
+
+ // remove
+ collection.schema.removeField("1ily0n9p")
+
+ // remove
+ collection.schema.removeField("8yxlysux")
+
+ // remove
+ collection.schema.removeField("twfa4xdq")
+
+ // remove
+ collection.schema.removeField("etzohhgx")
+
+ // remove
+ collection.schema.removeField("xw6z5two")
+
+ // remove
+ collection.schema.removeField("3kvrm6bs")
+
+ // remove
+ collection.schema.removeField("dv5s3tlf")
+
+ // remove
+ collection.schema.removeField("xi0zsmee")
+
+ // remove
+ collection.schema.removeField("tjjqxoin")
+
+ // remove
+ collection.schema.removeField("xt3tiocm")
+
+ // remove
+ collection.schema.removeField("8eknw7mm")
+
+ // remove
+ collection.schema.removeField("nrhmdzra")
+
+ return dao.saveCollection(collection)
+})
diff --git a/src/mothership-app/migrations/1702569370_updated_stats.js b/src/mothership-app/migrations/1702569370_updated_stats.js
new file mode 100644
index 00000000..50e95de6
--- /dev/null
+++ b/src/mothership-app/migrations/1702569370_updated_stats.js
@@ -0,0 +1,628 @@
+///
+migrate((db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("buq519uv711078p")
+
+ collection.options = {
+ "query": "SELECT\n (ROW_NUMBER() OVER()) as id,\n COUNT(DISTINCT users.id) AS total_users,\n COUNT(DISTINCT CASE WHEN users.subscription ='legacy' THEN users.id END) AS total_legacy_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription ='free' THEN users.id END) AS total_free_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'premium' THEN users.id END) AS total_pro_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'lifetime' THEN users.id END) AS total_lifetime_subscribers,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-1 hour') THEN users.id END) AS new_users_last_hour,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-24 hours') THEN users.id END) AS new_users_last_24_hours,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-7 days') THEN users.id END) AS new_users_last_7_days,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-30 days') THEN users.id END) AS new_users_last_30_days,\n COUNT(DISTINCT instances.id ) AS total_instances,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-1 hour') THEN instances.id END) AS total_instances_last_hour,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-24 hours') THEN instances.id END) AS total_instances_last_24_hours,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-7 days') THEN instances.id END) AS total_instances_last_7_days,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-30 days') THEN instances.id END) AS total_instances_last_30_days,\n \n COUNT(DISTINCT CASE WHEN instances.created > DATETIME('now', '-1 hour') THEN instances.id END) AS new_instances_last_hour,\n COUNT(DISTINCT CASE WHEN instances.created > DATETIME('now', '-24 hours') THEN instances.id END) AS new_instances_last_24_hours,\n COUNT(DISTINCT CASE WHEN instances.created > DATETIME('now', '-7 days') THEN instances.id END) AS new_instances_last_7_days,\n COUNT(DISTINCT CASE WHEN instances.created > DATETIME('now', '-30 days') THEN instances.id END) AS new_instances_last_30_days\n \nFROM\n verified_users users\nLEFT JOIN\n instances ON users.id = instances.uid;\n"
+ }
+
+ // remove
+ collection.schema.removeField("qxokezck")
+
+ // remove
+ collection.schema.removeField("nhnu96xj")
+
+ // remove
+ collection.schema.removeField("1ily0n9p")
+
+ // remove
+ collection.schema.removeField("8yxlysux")
+
+ // remove
+ collection.schema.removeField("twfa4xdq")
+
+ // remove
+ collection.schema.removeField("etzohhgx")
+
+ // remove
+ collection.schema.removeField("xw6z5two")
+
+ // remove
+ collection.schema.removeField("3kvrm6bs")
+
+ // remove
+ collection.schema.removeField("dv5s3tlf")
+
+ // remove
+ collection.schema.removeField("xi0zsmee")
+
+ // remove
+ collection.schema.removeField("tjjqxoin")
+
+ // remove
+ collection.schema.removeField("xt3tiocm")
+
+ // remove
+ collection.schema.removeField("8eknw7mm")
+
+ // remove
+ collection.schema.removeField("nrhmdzra")
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "gskg4kqa",
+ "name": "total_users",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "9b4pgxlv",
+ "name": "total_legacy_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "kgf9xbui",
+ "name": "total_free_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "2l3ym1mw",
+ "name": "total_pro_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "bxhkaly6",
+ "name": "total_lifetime_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "bmhsumvr",
+ "name": "new_users_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "jjlza3cn",
+ "name": "new_users_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "m51jsrba",
+ "name": "new_users_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "5jk6cpd0",
+ "name": "new_users_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "8fgyvqai",
+ "name": "total_instances",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "ewoabx5r",
+ "name": "total_instances_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "yjpzeew4",
+ "name": "total_instances_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "l6d6mc8b",
+ "name": "total_instances_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "i0pa9otz",
+ "name": "total_instances_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "zgjkjocr",
+ "name": "new_instances_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "vofl09ck",
+ "name": "new_instances_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "aww4v82e",
+ "name": "new_instances_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "pnko7ffx",
+ "name": "new_instances_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ return dao.saveCollection(collection)
+}, (db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("buq519uv711078p")
+
+ collection.options = {
+ "query": "SELECT\n (ROW_NUMBER() OVER()) as id,\n COUNT(DISTINCT users.id) AS total_users,\n COUNT(DISTINCT CASE WHEN users.subscription ='legacy' THEN users.id END) AS total_legacy_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription ='free' THEN users.id END) AS total_free_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'premium' THEN users.id END) AS total_pro_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'lifetime' THEN users.id END) AS total_lifetime_subscribers,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-1 hour') THEN users.id END) AS new_users_last_hour,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-24 hours') THEN users.id END) AS new_users_last_24_hours,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-7 days') THEN users.id END) AS new_users_last_7_days,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-30 days') THEN users.id END) AS new_users_last_30_days,\n\n COUNT(DISTINCT instances.id ) AS total_instances,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-1 hour') THEN instances.id END) AS total_instances_last_hour,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-24 hours') THEN instances.id END) AS total_instances_last_24_hours,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-7 days') THEN instances.id END) AS total_instances_last_7_days,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-30 days') THEN instances.id END) AS total_instances_last_30_days\nFROM\n verified_users users\nLEFT JOIN\n instances ON users.id = instances.uid;\n"
+ }
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "qxokezck",
+ "name": "total_users",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "nhnu96xj",
+ "name": "total_legacy_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "1ily0n9p",
+ "name": "total_free_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "8yxlysux",
+ "name": "total_pro_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "twfa4xdq",
+ "name": "total_lifetime_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "etzohhgx",
+ "name": "new_users_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "xw6z5two",
+ "name": "new_users_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "3kvrm6bs",
+ "name": "new_users_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "dv5s3tlf",
+ "name": "new_users_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "xi0zsmee",
+ "name": "total_instances",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "tjjqxoin",
+ "name": "total_instances_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "xt3tiocm",
+ "name": "total_instances_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "8eknw7mm",
+ "name": "total_instances_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "nrhmdzra",
+ "name": "total_instances_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // remove
+ collection.schema.removeField("gskg4kqa")
+
+ // remove
+ collection.schema.removeField("9b4pgxlv")
+
+ // remove
+ collection.schema.removeField("kgf9xbui")
+
+ // remove
+ collection.schema.removeField("2l3ym1mw")
+
+ // remove
+ collection.schema.removeField("bxhkaly6")
+
+ // remove
+ collection.schema.removeField("bmhsumvr")
+
+ // remove
+ collection.schema.removeField("jjlza3cn")
+
+ // remove
+ collection.schema.removeField("m51jsrba")
+
+ // remove
+ collection.schema.removeField("5jk6cpd0")
+
+ // remove
+ collection.schema.removeField("8fgyvqai")
+
+ // remove
+ collection.schema.removeField("ewoabx5r")
+
+ // remove
+ collection.schema.removeField("yjpzeew4")
+
+ // remove
+ collection.schema.removeField("l6d6mc8b")
+
+ // remove
+ collection.schema.removeField("i0pa9otz")
+
+ // remove
+ collection.schema.removeField("zgjkjocr")
+
+ // remove
+ collection.schema.removeField("vofl09ck")
+
+ // remove
+ collection.schema.removeField("aww4v82e")
+
+ // remove
+ collection.schema.removeField("pnko7ffx")
+
+ return dao.saveCollection(collection)
+})
diff --git a/src/mothership-app/migrations/1702569574_updated_stats.js b/src/mothership-app/migrations/1702569574_updated_stats.js
new file mode 100644
index 00000000..dacbc7d4
--- /dev/null
+++ b/src/mothership-app/migrations/1702569574_updated_stats.js
@@ -0,0 +1,704 @@
+///
+migrate((db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("buq519uv711078p")
+
+ collection.options = {
+ "query": "SELECT\n (ROW_NUMBER() OVER()) as id,\n \n COUNT(DISTINCT users.id) AS total_users,\n COUNT(DISTINCT CASE WHEN users.subscription ='legacy' THEN users.id END) AS total_legacy_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription ='free' THEN users.id END) AS total_free_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'premium' THEN users.id END) AS total_pro_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'lifetime' THEN users.id END) AS total_lifetime_subscribers,\n \n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-1 hour') THEN users.id END) AS new_users_last_hour,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-24 hours') THEN users.id END) AS new_users_last_24_hours,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-7 days') THEN users.id END) AS new_users_last_7_days,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-30 days') THEN users.id END) AS new_users_last_30_days,\n \n COUNT(DISTINCT instances.id ) AS total_instances,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-1 hour') THEN instances.id END) AS total_instances_last_hour,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-24 hours') THEN instances.id END) AS total_instances_last_24_hours,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-7 days') THEN instances.id END) AS total_instances_last_7_days,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-30 days') THEN instances.id END) AS total_instances_last_30_days,\n \n COUNT(DISTINCT CASE WHEN instances.created > DATETIME('now', '-1 hour') THEN instances.id END) AS new_instances_last_hour,\n COUNT(DISTINCT CASE WHEN instances.created > DATETIME('now', '-24 hours') THEN instances.id END) AS new_instances_last_24_hours,\n COUNT(DISTINCT CASE WHEN instances.created > DATETIME('now', '-7 days') THEN instances.id END) AS new_instances_last_7_days,\n COUNT(DISTINCT CASE WHEN instances.created > DATETIME('now', '-30 days') THEN instances.id END) AS new_instances_last_30_days\n \nFROM\n verified_users users\nLEFT JOIN\n instances ON users.id = instances.uid;\n"
+ }
+
+ // remove
+ collection.schema.removeField("gskg4kqa")
+
+ // remove
+ collection.schema.removeField("9b4pgxlv")
+
+ // remove
+ collection.schema.removeField("kgf9xbui")
+
+ // remove
+ collection.schema.removeField("2l3ym1mw")
+
+ // remove
+ collection.schema.removeField("bxhkaly6")
+
+ // remove
+ collection.schema.removeField("bmhsumvr")
+
+ // remove
+ collection.schema.removeField("jjlza3cn")
+
+ // remove
+ collection.schema.removeField("m51jsrba")
+
+ // remove
+ collection.schema.removeField("5jk6cpd0")
+
+ // remove
+ collection.schema.removeField("8fgyvqai")
+
+ // remove
+ collection.schema.removeField("ewoabx5r")
+
+ // remove
+ collection.schema.removeField("yjpzeew4")
+
+ // remove
+ collection.schema.removeField("l6d6mc8b")
+
+ // remove
+ collection.schema.removeField("i0pa9otz")
+
+ // remove
+ collection.schema.removeField("zgjkjocr")
+
+ // remove
+ collection.schema.removeField("vofl09ck")
+
+ // remove
+ collection.schema.removeField("aww4v82e")
+
+ // remove
+ collection.schema.removeField("pnko7ffx")
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "ocbcyask",
+ "name": "total_users",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "q5okyyvj",
+ "name": "total_legacy_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "a8mv3hbg",
+ "name": "total_free_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "bkn9fxd9",
+ "name": "total_pro_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "qkyv0nvm",
+ "name": "total_lifetime_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "g6hgzcbi",
+ "name": "new_users_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "6e2gep5p",
+ "name": "new_users_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "qdd2lgrg",
+ "name": "new_users_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "mdsqys16",
+ "name": "new_users_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "lz1oyvrc",
+ "name": "total_instances",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "ntg2cv49",
+ "name": "total_instances_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "o5o8e0a3",
+ "name": "total_instances_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "bi4hgf4i",
+ "name": "total_instances_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "e65bogl0",
+ "name": "total_instances_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "uxq8augl",
+ "name": "new_instances_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "w4k4qocm",
+ "name": "new_instances_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "vpbfbm1f",
+ "name": "new_instances_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "xactzvom",
+ "name": "new_instances_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ return dao.saveCollection(collection)
+}, (db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("buq519uv711078p")
+
+ collection.options = {
+ "query": "SELECT\n (ROW_NUMBER() OVER()) as id,\n COUNT(DISTINCT users.id) AS total_users,\n COUNT(DISTINCT CASE WHEN users.subscription ='legacy' THEN users.id END) AS total_legacy_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription ='free' THEN users.id END) AS total_free_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'premium' THEN users.id END) AS total_pro_subscribers,\n COUNT(DISTINCT CASE WHEN users.subscription= 'lifetime' THEN users.id END) AS total_lifetime_subscribers,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-1 hour') THEN users.id END) AS new_users_last_hour,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-24 hours') THEN users.id END) AS new_users_last_24_hours,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-7 days') THEN users.id END) AS new_users_last_7_days,\n COUNT(DISTINCT CASE WHEN users.created > DATETIME('now', '-30 days') THEN users.id END) AS new_users_last_30_days,\n COUNT(DISTINCT instances.id ) AS total_instances,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-1 hour') THEN instances.id END) AS total_instances_last_hour,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-24 hours') THEN instances.id END) AS total_instances_last_24_hours,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-7 days') THEN instances.id END) AS total_instances_last_7_days,\n COUNT(DISTINCT CASE WHEN instances.updated > DATETIME('now', '-30 days') THEN instances.id END) AS total_instances_last_30_days,\n \n COUNT(DISTINCT CASE WHEN instances.created > DATETIME('now', '-1 hour') THEN instances.id END) AS new_instances_last_hour,\n COUNT(DISTINCT CASE WHEN instances.created > DATETIME('now', '-24 hours') THEN instances.id END) AS new_instances_last_24_hours,\n COUNT(DISTINCT CASE WHEN instances.created > DATETIME('now', '-7 days') THEN instances.id END) AS new_instances_last_7_days,\n COUNT(DISTINCT CASE WHEN instances.created > DATETIME('now', '-30 days') THEN instances.id END) AS new_instances_last_30_days\n \nFROM\n verified_users users\nLEFT JOIN\n instances ON users.id = instances.uid;\n"
+ }
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "gskg4kqa",
+ "name": "total_users",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "9b4pgxlv",
+ "name": "total_legacy_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "kgf9xbui",
+ "name": "total_free_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "2l3ym1mw",
+ "name": "total_pro_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "bxhkaly6",
+ "name": "total_lifetime_subscribers",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "bmhsumvr",
+ "name": "new_users_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "jjlza3cn",
+ "name": "new_users_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "m51jsrba",
+ "name": "new_users_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "5jk6cpd0",
+ "name": "new_users_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "8fgyvqai",
+ "name": "total_instances",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "ewoabx5r",
+ "name": "total_instances_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "yjpzeew4",
+ "name": "total_instances_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "l6d6mc8b",
+ "name": "total_instances_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "i0pa9otz",
+ "name": "total_instances_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "zgjkjocr",
+ "name": "new_instances_last_hour",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "vofl09ck",
+ "name": "new_instances_last_24_hours",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "aww4v82e",
+ "name": "new_instances_last_7_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // add
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "pnko7ffx",
+ "name": "new_instances_last_30_days",
+ "type": "number",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "min": null,
+ "max": null,
+ "noDecimal": false
+ }
+ }))
+
+ // remove
+ collection.schema.removeField("ocbcyask")
+
+ // remove
+ collection.schema.removeField("q5okyyvj")
+
+ // remove
+ collection.schema.removeField("a8mv3hbg")
+
+ // remove
+ collection.schema.removeField("bkn9fxd9")
+
+ // remove
+ collection.schema.removeField("qkyv0nvm")
+
+ // remove
+ collection.schema.removeField("g6hgzcbi")
+
+ // remove
+ collection.schema.removeField("6e2gep5p")
+
+ // remove
+ collection.schema.removeField("qdd2lgrg")
+
+ // remove
+ collection.schema.removeField("mdsqys16")
+
+ // remove
+ collection.schema.removeField("lz1oyvrc")
+
+ // remove
+ collection.schema.removeField("ntg2cv49")
+
+ // remove
+ collection.schema.removeField("o5o8e0a3")
+
+ // remove
+ collection.schema.removeField("bi4hgf4i")
+
+ // remove
+ collection.schema.removeField("e65bogl0")
+
+ // remove
+ collection.schema.removeField("uxq8augl")
+
+ // remove
+ collection.schema.removeField("w4k4qocm")
+
+ // remove
+ collection.schema.removeField("vpbfbm1f")
+
+ // remove
+ collection.schema.removeField("xactzvom")
+
+ return dao.saveCollection(collection)
+})