User growth by month view

This commit is contained in:
Ben Allfree 2023-12-24 14:12:57 +00:00
parent fff78968e3
commit b6fcc1a9aa
5 changed files with 389 additions and 0 deletions

View File

@ -0,0 +1,55 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const collection = new Collection({
"id": "7vzz1jr2us7mwmx",
"created": "2023-12-14 16:30:33.330Z",
"updated": "2023-12-14 16:30:33.330Z",
"name": "user_growth_by_month",
"type": "view",
"system": false,
"schema": [
{
"system": false,
"id": "r2f9pxks",
"name": "created_month",
"type": "json",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSize": 1
}
},
{
"system": false,
"id": "hfwcgpmi",
"name": "number_of_users",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"noDecimal": false
}
}
],
"indexes": [],
"listRule": null,
"viewRule": null,
"createRule": null,
"updateRule": null,
"deleteRule": null,
"options": {
"query": "SELECT \n (ROW_NUMBER() OVER()) as id,\n strftime('%Y-%m', created) AS created_month, \n COUNT(*) AS number_of_users \nFROM \n users \nGROUP BY \n created_month\n\torder by created_month asc\n"
}
});
return Dao(db).saveCollection(collection);
}, (db) => {
const dao = new Dao(db);
const collection = dao.findCollectionByNameOrId("7vzz1jr2us7mwmx");
return dao.deleteCollection(collection);
})

View File

@ -0,0 +1,75 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("7vzz1jr2us7mwmx")
collection.options = {
"query": "SELECT \n (ROW_NUMBER() OVER()) as id,\n strftime('%Y-%m', created) AS created, \n COUNT(*) AS total \nFROM \n users \nGROUP BY \n created\n\torder by created asc\n"
}
// remove
collection.schema.removeField("r2f9pxks")
// remove
collection.schema.removeField("hfwcgpmi")
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "q1td6nqz",
"name": "total",
"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("7vzz1jr2us7mwmx")
collection.options = {
"query": "SELECT \n (ROW_NUMBER() OVER()) as id,\n strftime('%Y-%m', created) AS created_month, \n COUNT(*) AS number_of_users \nFROM \n users \nGROUP BY \n created_month\n\torder by created_month asc\n"
}
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "r2f9pxks",
"name": "created_month",
"type": "json",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSize": 1
}
}))
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "hfwcgpmi",
"name": "number_of_users",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"noDecimal": false
}
}))
// remove
collection.schema.removeField("q1td6nqz")
return dao.saveCollection(collection)
})

View File

@ -0,0 +1,75 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("7vzz1jr2us7mwmx")
collection.options = {
"query": "SELECT \n (ROW_NUMBER() OVER()) as id,\n strftime('%Y-%m', created) AS t, \n COUNT(*) AS c \nFROM \n users \nGROUP BY \n t\n\torder by t asc\n"
}
// remove
collection.schema.removeField("q1td6nqz")
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "6w2uyzd9",
"name": "t",
"type": "json",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSize": 1
}
}))
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "ytpf0f1l",
"name": "c",
"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("7vzz1jr2us7mwmx")
collection.options = {
"query": "SELECT \n (ROW_NUMBER() OVER()) as id,\n strftime('%Y-%m', created) AS created, \n COUNT(*) AS total \nFROM \n users \nGROUP BY \n created\n\torder by created asc\n"
}
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "q1td6nqz",
"name": "total",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"noDecimal": false
}
}))
// remove
collection.schema.removeField("6w2uyzd9")
// remove
collection.schema.removeField("ytpf0f1l")
return dao.saveCollection(collection)
})

View File

@ -0,0 +1,92 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("7vzz1jr2us7mwmx")
collection.options = {
"query": "SELECT \n (ROW_NUMBER() OVER()) as id,\n strftime('%Y-%m', created) AS t, \n COUNT(*) AS c \nFROM \n users \nGROUP BY \n t\n\torder by t desc\n"
}
// remove
collection.schema.removeField("6w2uyzd9")
// remove
collection.schema.removeField("ytpf0f1l")
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "ee4obryu",
"name": "t",
"type": "json",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSize": 1
}
}))
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "kq8xt1mi",
"name": "c",
"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("7vzz1jr2us7mwmx")
collection.options = {
"query": "SELECT \n (ROW_NUMBER() OVER()) as id,\n strftime('%Y-%m', created) AS t, \n COUNT(*) AS c \nFROM \n users \nGROUP BY \n t\n\torder by t asc\n"
}
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "6w2uyzd9",
"name": "t",
"type": "json",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSize": 1
}
}))
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "ytpf0f1l",
"name": "c",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"noDecimal": false
}
}))
// remove
collection.schema.removeField("ee4obryu")
// remove
collection.schema.removeField("kq8xt1mi")
return dao.saveCollection(collection)
})

View File

@ -0,0 +1,92 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("7vzz1jr2us7mwmx")
collection.options = {
"query": "SELECT \n (ROW_NUMBER() OVER()) as id,\n strftime('%Y-%m', created) AS t, \n COUNT(*) AS c \nFROM \n verified_users as users\nGROUP BY \n t\n\torder by t desc\n"
}
// remove
collection.schema.removeField("ee4obryu")
// remove
collection.schema.removeField("kq8xt1mi")
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "pk5at00z",
"name": "t",
"type": "json",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSize": 1
}
}))
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "3ybi74j4",
"name": "c",
"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("7vzz1jr2us7mwmx")
collection.options = {
"query": "SELECT \n (ROW_NUMBER() OVER()) as id,\n strftime('%Y-%m', created) AS t, \n COUNT(*) AS c \nFROM \n users \nGROUP BY \n t\n\torder by t desc\n"
}
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "ee4obryu",
"name": "t",
"type": "json",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSize": 1
}
}))
// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "kq8xt1mi",
"name": "c",
"type": "number",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"noDecimal": false
}
}))
// remove
collection.schema.removeField("pk5at00z")
// remove
collection.schema.removeField("3ybi74j4")
return dao.saveCollection(collection)
})