Skip to content

Commit

Permalink
Merge pull request #23 from google-marketing-solutions/fixing-styles
Browse files Browse the repository at this point in the history
conforming to style guidelines
  • Loading branch information
betocollin authored Jan 28, 2025
2 parents 4f7b084 + c5480ee commit b73c690
Show file tree
Hide file tree
Showing 35 changed files with 286 additions and 181 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
159 changes: 117 additions & 42 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions ai_bubbles/bq.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ const lighterQueries = {
${projectId}.${datasetId}_bq.campaign_data
GROUP BY 1, 2, 3
ORDER BY date DESC`,

"campaigns_assets_count": `
SELECT
SELECT
campaign_name,
account_name,
has_product_feed,
Expand Down Expand Up @@ -109,7 +109,7 @@ function getInsertQueryForInsights(data) {
INSERT INTO
\`${projectId}.${datasetId}_bq.insights\`
(insights, headline, table, date)
VALUES
VALUES
("${escapedInsights}",
"${escapedHeadline}",
"${record.table}",
Expand Down
6 changes: 4 additions & 2 deletions ai_bubbles/bq.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ describe("getInsertQueryForInsights", () => {
const data = [
{
insights: "test1",
table: "anything1"
table: "anything1",
headline: "headline1"
},
{
insights: "test2",
table: "anything2"
table: "anything2",
headline: "headline2"
}
]

Expand Down
20 changes: 10 additions & 10 deletions ai_bubbles/gemini.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ const promptsByTableName = {
best practices?`,

contextAndExamples: `
I have attached a file to help with this analysis
I have attached a file to help with this analysis
with an explanation of what's included. If you do not receive a file,
please let me know.
Bid & Budget contains campaign performance data including conversions,
daily budget and whether a campaign has a lookalike audience.
Expand Down Expand Up @@ -70,7 +70,7 @@ const promptsByTableName = {
`,
requirementsAndInstructions: `
The headline should be written with an attention grabbing headline that a
senior manager would respond positively to. It should be concise (less
senior manager would respond positively to. It should be concise (less
than 50 characters).`
}
},
Expand All @@ -84,10 +84,10 @@ const promptsByTableName = {
contextAndExamples: `
I have attached a file to help with this analysis with an explanation of
what's included. If you do not receive a file, please let me know.
The file contains creative asset coverage information as well as a column
to indicate whether a product feed is included.
The best practice for Demand Gen campaigns is as follows:
Use Image & Video together for better performance. Including 3 of each
image format (vertical, horizontal), 3 of each video format (horizontal,
Expand All @@ -113,7 +113,7 @@ const promptsByTableName = {
`,
requirementsAndInstructions: `
The headline should be written with an attention grabbing headline that a
senior manager would respond positively to. It should be concise (less
senior manager would respond positively to. It should be concise (less
than 50 characters).`
}
}
Expand All @@ -138,7 +138,7 @@ async function getRespectivePromptResponse(uploadResult, table, insights) {
console.log('geminiTextResponse:', geminiTextResponse);

return geminiTextResponse;

} catch (error) {
console.error('Error:', error);
}
Expand Down Expand Up @@ -172,9 +172,9 @@ async function getGeminiResponseFromCSV(
const prompt = promptsByTableName[table][promptType].roleAndTask
+ (promptsByTableName[table][promptType].contextAndExamples || insights)
+ promptsByTableName[table][promptType].requirementsAndInstructions;

console.log('prompt:' + promptType + " -- "+ prompt)

const result = await model.generateContent([
prompt,
{
Expand All @@ -193,4 +193,4 @@ module.exports = {
getRespectivePromptResponse,
uploadFileToGoogleAiStorage,
getGeminiResponseFromCSV
};
};
4 changes: 1 addition & 3 deletions ai_bubbles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ functions.http("aiBubblesGET", async (req, res) => {
// campaign_assets_count represents "Creative Asset Coverage" in the UI:
inserts.push(
await gemini.getInsightsAndHeadlineForTable('campaigns_assets_count'));

await bq.insertIntoInsights(inserts);

res.send("Finished");
});


2 changes: 1 addition & 1 deletion ai_bubbles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
"resetMocks": true,
"restoreMocks": true
}
}
}
2 changes: 1 addition & 1 deletion answers.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
"account_conversion_action": "account_conversion_action",
"insights": "insights"
}
}
}
6 changes: 3 additions & 3 deletions bq_queries/01-campaign_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
/*
This script will create a dataset for the post processing queries and it will organize
This script will create a dataset for the post processing queries and it will organize
data from campaigns and link external account ids to ocid (OperatingCustomerId)
to generate the deep link URLs.
@param {bq_dataset} to be replaced by the answers.json's respective value (e.g.:dgpulse).
*/

Expand Down Expand Up @@ -94,4 +94,4 @@ FROM
LEFT JOIN `{bq_dataset}.ocid_mapping` AS OCID ON OCID.customer_id = C.account_id
LEFT JOIN `{bq_dataset}.customer` AS CUST ON CUST.account_id = C.account_id
LEFT JOIN `{bq_dataset}_reference_data.exchange_rates` AS ER ON CUST.currency_code = ER.target_currency
LEFT JOIN campaigns_with_lookalikes AS CWL ON C.campaign_id = CWL.campaign_id;
LEFT JOIN campaigns_with_lookalikes AS CWL ON C.campaign_id = CWL.campaign_id;
2 changes: 1 addition & 1 deletion bq_queries/02-video_aspect_ratio.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ FROM
CROSS JOIN UNNEST(AGA_VID_SPLIT.dvra_videos) AS dvra_videos
LEFT JOIN
`{bq_dataset}.asset` AS A
ON dvra_videos = cast(A.asset_id AS string);
ON dvra_videos = cast(A.asset_id AS string);
10 changes: 5 additions & 5 deletions bq_queries/03-campaigns_assets_count.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
Copyright 2024 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -16,7 +16,7 @@
/*
This script will combine data from campaigns, ocid (OperatingCustomerId which contains the
id to generate deep links) and video aspect ratios counts into a single BQ Table.
@param {bq_dataset} to be replaced by the answers.json's respective value (e.g.:dgpulse).
*/
CREATE
Expand Down Expand Up @@ -117,4 +117,4 @@ OR REPLACE TABLE `{bq_dataset}_bq.campaigns_assets_count` AS (
INNER JOIN OperatingCustomerId ON OperatingCustomerId.account_id = AdGroupAd.account_id
INNER JOIN CampaignData ON CampaignData.campaign_id = AdGroupAd.campaign_id
LEFT JOIN VideoAspectRatioCount ON VideoAspectRatioCount.campaign_id = AdGroupAd.campaign_id
);
);
2 changes: 1 addition & 1 deletion bq_queries/04-campaign_conversion_actions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ LEFT JOIN CONVERSION_ACTION_CATEGORY_COUNTS AS CACC
LEFT JOIN ACCOUNT_DDA AS ADDA
USING (account_id)
LEFT JOIN `{bq_dataset}.customer` AS C
USING (account_id);
USING (account_id);
2 changes: 1 addition & 1 deletion bq_queries/05-audience_performance.sql
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ AS (
audience_name,
audience_type,
ocid
);
);
10 changes: 5 additions & 5 deletions bq_queries/06-assets_performance.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
/*
This script will create a dataset for the post processing queries and it will organize
This script will create a dataset for the post processing queries and it will organize
data from campaigns and link external account ids to ocid (OperatingCustomerId)
to generate the deep link URLs.
@param {bq_dataset} to be replaced by the answers.json's respective value (e.g.:dgpulse).
*/

Expand All @@ -32,8 +32,8 @@ WITH
campaign_name,
date,
image_url,
SUBSTR(asset_type_inferred,
LENGTH(asset_type_inferred)
SUBSTR(asset_type_inferred,
LENGTH(asset_type_inferred)
- STRPOS(REVERSE(asset_type_inferred), '~') + 2)
AS asset_type_inferred,
SUM(clicks) AS clicks,
Expand Down Expand Up @@ -86,4 +86,4 @@ SELECT
cost / 1e6 AS cost
FROM AssetsPerformance
INNER JOIN `{bq_dataset}.ocid_mapping` AS OCID
ON OCID.customer_id = account_id;
ON OCID.customer_id = account_id;
2 changes: 1 addition & 1 deletion get-accounts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
SELECT customer.id
FROM campaign
WHERE campaign.advertising_channel_type = "DEMAND_GEN"
AND campaign.status = 'ENABLED'
AND campaign.status = 'ENABLED'
2 changes: 1 addition & 1 deletion google_ads_queries/account_dda.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ FROM
conversion_action
WHERE
conversion_action.attribution_model_settings.attribution_model = "GOOGLE_SEARCH_ATTRIBUTION_DATA_DRIVEN"
AND conversion_action.status = "ENABLED"
AND conversion_action.status = "ENABLED"
2 changes: 1 addition & 1 deletion google_ads_queries/ad_group_ad.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ WHERE
campaign.advertising_channel_type = 'DEMAND_GEN'
AND campaign.status = 'ENABLED'
AND ad_group_ad.status = 'ENABLED'
-- SQLSTYLE: Notice that semi-colon (;) at the end of the script is not allowed by gaarf.
-- SQLSTYLE: Notice that semi-colon (;) at the end of the script is not allowed by gaarf.
10 changes: 5 additions & 5 deletions google_ads_queries/ad_group_criterion.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
Copyright 2024 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -16,7 +16,7 @@
/*
This script will be used by gaarf to fetch Audience Performance data
for a given date range from Google Ads API and store in a BQ Table.
@param {start_date} The start date of the date range.
@param {end_date} The end date of the date range.
*/
Expand All @@ -29,4 +29,4 @@ WHERE
ad_group_criterion.type = 'USER_LIST'
AND user_list.type = 'LOOKALIKE'
AND ad_group_criterion.status = 'ENABLED'
-- SQLSTYLE: Notice that semi-colon (;) at the end of the script is not allowed by gaarf.
-- SQLSTYLE: Notice that semi-colon (;) at the end of the script is not allowed by gaarf.
10 changes: 5 additions & 5 deletions google_ads_queries/adgroupad_asset_view.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
Copyright 2024 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -16,7 +16,7 @@
/*
This script will be used by gaarf to fetch ad_group_ad_asset_view
for a given date range from Google Ads API and store in a BQ Table.
@param {start_date} The start date of the date range.
@param {end_date} The end date of the date range.
*/
Expand All @@ -37,4 +37,4 @@ SELECT
WHERE segments.date >= "{start_date}"
AND segments.date <= "{end_date}"
AND campaign.advertising_channel_type = "DEMAND_GEN"
-- SQLSTYLE: Notice that semi-colon (;) at the end of the script is not allowed by gaarf.
-- SQLSTYLE: Notice that semi-colon (;) at the end of the script is not allowed by gaarf.
2 changes: 1 addition & 1 deletion google_ads_queries/asset.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ SELECT
asset.youtube_video_asset.youtube_video_id AS video_id
FROM
asset
WHERE asset.type = "YOUTUBE_VIDEO"
WHERE asset.type = "YOUTUBE_VIDEO"
10 changes: 5 additions & 5 deletions google_ads_queries/audience_metrics.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
Copyright 2024 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -16,7 +16,7 @@
/*
This script will be used by gaarf to fetch Audience Performance data
for a given date range from Google Ads API and store in a BQ Table.
@param {start_date} The start date of the date range.
@param {end_date} The end date of the date range.
*/
Expand All @@ -40,4 +40,4 @@ WHERE
AND segments.date >= '{start_date}'
AND segments.date <= '{end_date}'
AND campaign.status = 'ENABLED'
-- SQLSTYLE: Notice that semi-colon (;) at the end of the script is not allowed by gaarf.
-- SQLSTYLE: Notice that semi-colon (;) at the end of the script is not allowed by gaarf.
2 changes: 1 addition & 1 deletion google_ads_queries/campaign_conversion_action_category.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ WHERE
AND segments.conversion_action_category != "DEFAULT"
AND campaign.status = "ENABLED"
AND segments.date >= "{start_date}"
AND segments.date <= "{end_date}"
AND segments.date <= "{end_date}"
2 changes: 1 addition & 1 deletion google_ads_queries/campaign_settings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ FROM campaign
WHERE
campaign.advertising_channel_type = "DEMAND_GEN"
AND segments.date >= "{start_date}"
AND segments.date <= "{end_date}"
AND segments.date <= "{end_date}"
2 changes: 1 addition & 1 deletion google_ads_queries/customer.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ SELECT
customer.currency_code AS currency_code,
customer.conversion_tracking_setting.enhanced_conversions_for_leads_enabled AS ecl_enabled
FROM
customer
customer
2 changes: 1 addition & 1 deletion google_ads_queries/ocid_mapping.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
-- This is a GAARF capability that makes it possible
-- to add links to the dashboard later.
-- GAARF docs: https://github.com/google/ads-api-report-fetcher
SELECT * FROM builtin.ocid_mapping;
SELECT * FROM builtin.ocid_mapping;
Loading

0 comments on commit b73c690

Please sign in to comment.