diff --git a/db/migrations/1719855101866-Data.js b/db/migrations/1719855101866-Data.js new file mode 100644 index 000000000..77f65556e --- /dev/null +++ b/db/migrations/1719855101866-Data.js @@ -0,0 +1,13 @@ +module.exports = class Data1719855101866 { + name = 'Data1719855101866' + + async up(db) { + await db.query(`CREATE TABLE "admin"."user_interaction_count" ("id" character varying NOT NULL, "type" text, "entity_id" text, "day_timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "count" integer NOT NULL, CONSTRAINT "PK_8e334a51febcf02c54dff48147d" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_b5261af5f3fe48d77086ebc602" ON "admin"."user_interaction_count" ("day_timestamp") `) + } + + async down(db) { + await db.query(`DROP TABLE "admin"."user_interaction_count"`) + await db.query(`DROP INDEX "admin"."IDX_b5261af5f3fe48d77086ebc602"`) + } +} diff --git a/db/migrations/1709641962433-Views.js b/db/migrations/1719855101957-Views.js similarity index 93% rename from db/migrations/1709641962433-Views.js rename to db/migrations/1719855101957-Views.js index 98cd8871f..d4c237e43 100644 --- a/db/migrations/1709641962433-Views.js +++ b/db/migrations/1719855101957-Views.js @@ -1,8 +1,8 @@ const { getViewDefinitions } = require('../viewDefinitions') -module.exports = class Views1709641962433 { - name = 'Views1709641962433' +module.exports = class Views1719855101957 { + name = 'Views1719855101957' async up(db) { // these two queries will be invoked and the cleaned up by the squid itself @@ -30,8 +30,6 @@ module.exports = class Views1709641962433 { `); } } - - } async down(db) { @@ -39,6 +37,5 @@ module.exports = class Views1709641962433 { for (const viewName of Object.keys(viewDefinitions)) { await db.query(`DROP VIEW "${viewName}"`) } - } } diff --git a/schema/events.graphql b/schema/events.graphql index badcf357d..c4b2dfbcc 100644 --- a/schema/events.graphql +++ b/schema/events.graphql @@ -505,3 +505,20 @@ type CreatorTokenRevenueSplitIssuedEventData { "Details of the revenue split" revenueShare: RevenueShare } + +type UserInteractionCount @entity @schema(name: "admin") { + "Autoincremented ID" + id: ID! + + "Type of the user interaction eg. 'tokenMarketplaceEntry'" + type: String + + "ID of the entity that the event is related to for 'tokenMarketplaceEntry' it would be token ID" + entityId: String + + "Timestamp of the day that is used to count the interactions" + dayTimestamp: DateTime! @index + + "Count of the interactions" + count: Int! +}