@itleanchatbot/shared-models-js-postgres 3.1.3 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itleanchatbot/shared-models-js-postgres",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "description": "Shared Models JS Postgres",
5
5
  "main": "index.js",
6
6
  "license": "ISC",
@@ -1,43 +0,0 @@
1
- /** 20250819-create-view-channel_message_type_daily */
2
- module.exports = {
3
- up: async queryInterface => {
4
- await queryInterface.sequelize.query(`
5
- DROP VIEW IF EXISTS channel_message_type_daily;
6
- CREATE VIEW channel_message_type_daily AS
7
- SELECT
8
- (bi."createdAt")::date AS day,
9
- bi."EnterpriseId" AS "EnterpriseId",
10
- s."ChannelId" AS "ChannelId",
11
- ch.name AS "channelName",
12
- CASE
13
- WHEN
14
- -- transcrição presente no inbound_message => áudio
15
- ((bi.context::jsonb #> '{inbound_message,payload,payload}') ? 'transcription') OR
16
- ((bi.context::jsonb #> '{inboundMessage,payload,payload}') ? 'transcription') OR
17
- -- tipo audio no inbound
18
- ((bi.context::jsonb #>> '{inbound_message,payload,payload,type}') = 'audio') OR
19
- ((bi.context::jsonb #>> '{inboundMessage,payload,payload,type}') = 'audio') OR
20
- -- contentType de áudio em qualquer um dos lugares usuais
21
- ((bi.context::jsonb #>> '{inbound_message,payload,payload,contentType}') ILIKE 'audio/%') OR
22
- ((bi.context::jsonb #>> '{inboundMessage,payload,payload,contentType}') ILIKE 'audio/%') OR
23
- ((coalesce(bi.payload, '{}'::jsonb) ->> 'mimetype') ILIKE 'audio/%') OR
24
- -- fallback mínimo: nossa flag explícita
25
- (bi.message = 'whatsapp_gupshup_audio')
26
- THEN 'audio'
27
- ELSE 'text'
28
- END AS "messageType",
29
- COUNT(*) AS total
30
- FROM "BotIterables" bi
31
- LEFT JOIN "Sessions" s ON s.id = bi."SessionId"
32
- LEFT JOIN "Channels" ch ON ch.id = s."ChannelId"
33
- WHERE bi.action = 'client'
34
- AND bi.type = 'message'
35
- GROUP BY day, bi."EnterpriseId", s."ChannelId", ch.name, "messageType";
36
- `)
37
- },
38
- down: async queryInterface => {
39
- await queryInterface.sequelize.query(`
40
- DROP VIEW IF EXISTS channel_message_type_daily;
41
- `)
42
- },
43
- }