Skip to content

Commit

Permalink
#29862 CA CubeJS Schema first version (#30039)
Browse files Browse the repository at this point in the history
### Proposed Changes
* First version of the CA CubeJS Schema
  • Loading branch information
freddyDOTCMS authored Sep 17, 2024
1 parent a0138dc commit b4acc93
Showing 1 changed file with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,72 @@ cube(`Events`, {
}
},
dataSource: `default`
});
});

cube('request', {
sql: `SELECT request_id,
MAX(sessionid) as sessionid,
(MAX(sessionnew) == 1)::bool as isSessionNew,
MIN(utc_time) as createdAt,
MAX(source_ip) as source_ip,
MAX(language) as language,
MAX(user_agent) as user_agent,
MAX(host) as host,
MAX(CASE WHEN event_type = 'PAGE_REQUEST' THEN object_id ELSE NULL END) as page_id,
MAX(CASE WHEN event_type = 'PAGE_REQUEST' THEN object_title ELSE NULL END) as page_title,
MAX(CASE WHEN event_type = 'FILE_REQUEST' THEN object_id ELSE NULL END) as file_id,
MAX(CASE WHEN event_type = 'FILE_REQUEST' THEN object_title ELSE NULL END) as file_title,
MAX(CASE WHEN event_type = 'VANITY_REQUEST' THEN object_id ELSE NULL END) as vanity_id,
MAX(CASE WHEN event_type = 'VANITY_REQUEST' THEN object_forward_to ELSE NULL END) as vanity_forward_to,
MAX(CASE WHEN event_type = 'VANITY_REQUEST' THEN object_response ELSE NULL END) as vanity_response,
(SUM(CASE WHEN event_type = 'VANITY_REQUEST' THEN 1 ELSE 0 END) > 0)::bool as was_vanity_url_hit,
MAX(CASE WHEN event_type = 'VANITY_REQUEST' THEN comefromvanityurl ELSE NULL END) as come_from_vanity_url,
(SUM(CASE WHEN event_type = 'URL_MAP' THEN 1 ELSE 0 END) > 0)::bool as url_map_match,
MAX(CASE WHEN event_type = 'URL_MAP' THEN object_id ELSE NULL END) as url_map_content_detail_id,
MAX(CASE WHEN event_type = 'URL_MAP' THEN object_title ELSE NULL END) as url_map_content_detail_title,
MAX(CASE WHEN event_type = 'URL_MAP' THEN object_content_type_id ELSE NULL END) as url_map_content_type_id,
MAX(CASE WHEN event_type = 'URL_MAP' THEN object_content_type_name ELSE NULL END) as url_map_content_type_name,
MAX(CASE WHEN event_type = 'URL_MAP' THEN object_content_type_var_name ELSE NULL END) as url_map_content_type_var_name,
MAX(CASE WHEN event_type = 'URL_MAP' THEN object_detail_page_url ELSE NULL END) as url_map_detail_page_url,
MAX(url) AS url,
CASE
WHEN MAX(CASE WHEN event_type = 'FILE_REQUEST' THEN 1 ELSE 0 END) = 1 THEN 'FILE'
WHEN MAX(CASE WHEN event_type = 'PAGE_REQUEST' THEN 1 ELSE 0 END) = 1 THEN 'PAGE'
ELSE 'NOTHING'
END AS what_am_i
FROM events
GROUP BY request_id`,
dimensions: {
requestId: { sql: 'request_id', type: `string` },
sessionId: { sql: 'sessionid', type: `string` },
isSessionNew: { sql: 'isSessionNew', type: `boolean` },
createdAt: { sql: 'createdAt', type: `time`, },
whatAmI: { sql: 'what_am_i', type: `string` },
sourceIp: { sql: 'source_ip', type: `string` },
language: { sql: 'language', type: `string` },
userAgent: { sql: 'user_agent', type: `string` },
host: { sql: 'host', type: `string` },
url: { sql: 'url', type: `string` },
pageId: { sql: 'page_id', type: `string` },
pageTitle: { sql: 'page_title', type: `string` },
fileId: { sql: 'file_id', type: `string` },
fileTitle: { sql: 'file_title', type: `string` },
wasVanityHit: { sql: 'was_vanity_url_hit', type: `boolean` },
vanityId: { sql: 'vanity_id', type: `string` },
vanityForwardTo: { sql: 'vanity_forward_to', type: `string` },
vanityResponse: { sql: 'vanity_response', type: `string` },
comeFromVanityURL: { sql: 'come_from_vanity_url', type: `boolean` },
urlMapWasHit: { sql: 'url_map_match', type: `boolean` },
isDetailPage: { sql: "url_map_detail_page_url is not null and url_map_detail_page_url != ''", type: `boolean` },
urlMapContentDetailId: { sql: 'url_map_content_detail_id', type: `string` },
urlMapContentDetailTitle: { sql: 'url_map_content_detail_title', type: `string` },
urlMapContentId: { sql: 'url_map_content_type_id', type: `string` },
urlMapContentTypeName: { sql: 'url_map_content_type_name', type: `string` },
urlMapContentTypeVarName: { sql: 'url_map_content_type_var_name', type: `string` },
},
measures: {
count: {
type: "count"
}
}
});

0 comments on commit b4acc93

Please sign in to comment.