Skip to content

Commit

Permalink
Merge branch 'main' into chore_ch_sink_bump_2_5_0
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelchris authored Dec 26, 2024
2 parents 339d096 + 6ea4afa commit a049567
Show file tree
Hide file tree
Showing 18 changed files with 285 additions and 82 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: 2.1
orbs:
gcp-gcr: circleci/[email protected].2
gcp-gcr: circleci/[email protected].9
pulumi: pulumi/[email protected]
gcp-cli: circleci/gcp-cli@3.1.1
gcp-cli: circleci/gcp-cli@3.3.0
jobs:
build:
docker:
Expand All @@ -29,7 +29,7 @@ jobs:
resource_class: large
docker:
- image: cimg/node:20.12
- image: postgres:15-alpine
- image: postgres:17-alpine
environment:
- POSTGRES_DB: api_test
- POSTGRES_PASSWORD: 12345
Expand Down
2 changes: 0 additions & 2 deletions .infra/Pulumi.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,3 @@ config:
secure: AAABAAM5O5jYZ5WIiAhtr3FpVoDQWP9nOjozE2LQsAiJVX0kGhOLMCueVKekPaz8yB6efNak8NOxu2WiGdcZTIE66KqvqQaqL5WrQD3938TWusE+8YtM8pvxNRhIZ4fYxcgGCJmSgFX/kBEnrmB9HqHz77eL6czuAUgakrwXni9a26rLPYlHNt3UGqMhLdSIuxGrlKo46aTy3ms/1kHJq0h5i4wODah6J9r0Br2nfGmXkvoMuwQGGKt4Iz+MN4lS2IlmwSB2nDlgJNsGvQdgPshx+/w4iDh8KucFPhRvXMwHFwWiW/8MM1oDNT1f3YtPQC7eFjok3qJS6SjLkQD9S//cgW95/0M45MtIJGCZWNvqRyKR0CgzEwhFjmN9pqiIe+URIMU8YN1D9GgjZz/b72T4owPliTswhFBNpjyru86OyUYaAIXJ1x0SXNYNgFSCl3gXV+cEsQIndhxsjHgIMkV5KJri/IQkzSXGSlgoxlta0m7p3JLbX10/vjCAlSPTk1UXRuegGUyvgtubiam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TnApKxcSpK7o8evh1pylChH+YC2Ggkw/EsAXkduM7ozfLbRuT5MQVH/KvX+lKBkkSjnDf+Ii2jYSMLr6Ukax1Jnm+kCMgmhgoAS6+PA4DKxQlOWjYXHoUaswaCWLWetP9MTu+VxcaoKfntbvrDp965GceH9Co6nTUCZQifiBewP8v/rUNDYNIprueizd3EpiCblntRXWHLEpCzREjeAJwpJwhHcJdHpvaKRMIvH8lK1700dc4WAjvVaDpvOpzAaROcplYcB5OPahxE6ZYFbAUEDSzDQn+iWUnzCFagdH1Y6N+UP61C2bwB/vqQDpk5j3CO6RnNTnQPsdLCfD55k8Y4hmREQEMviGIJUJAR2jTRAGXOZD/f+j7fZ1SFBlpqYywpQQhiVxp9ngOBa8eQL6C8UJF+19/ho6zklGtVmwGEPJXD4fCz+zImfw4a44NJzy6gHf6qDqyg/pAonAff74u768jRK1OXT13DlGmdyIH859W33xF4tL68RqzjYgi2+wPRiXZMD2NMqszz8seARGC+C9O7xG/tOZWGQkNzCmfqJvm/xRQdr8upHMz+tLKGtnpQiVWWKXvQI4GTE7OCfy72tDrYCHEN2LxPsFGNFgShqqH33HgNZA/V7L
gcp:project: devkit-prod
gcp:region: us-central1
api:projectNumber:
secure: AAABAB3AC0Ld1HpbfvRKrtr6+/b6W/kD1i8iLiLUqxv5CII2vktsPcBXiIE=
2 changes: 1 addition & 1 deletion .infra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ const [apps] = deployApplicationSuite(
],
},
debezium: {
version: '2.4.2.Final',
version: '3.0.5.Final',
topicName: debeziumTopicName,
propsPath: './application.properties',
propsVars: {
Expand Down
18 changes: 9 additions & 9 deletions .infra/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"@types/node": "20.12.x"
},
"dependencies": {
"@dailydotdev/pulumi-common": "^2.4.5",
"@dailydotdev/pulumi-common": "^2.4.6",
"@pulumi/gcp": "^8.10.2",
"@pulumi/kubernetes": "^4.19.0",
"@pulumi/pulumi": "^3.143.0"
Expand Down
22 changes: 22 additions & 0 deletions __tests__/boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import { DEFAULT_TIMEZONE, submitArticleThreshold } from '../src/common';
import { saveReturnAlerts } from '../src/schema/alerts';
import { UserVote } from '../src/types';
import { BootAlerts, excludeProperties } from '../src/routes/boot';
import { SubscriptionCycles } from '../src/paddle';

let app: FastifyInstance;
let con: DataSource;
Expand Down Expand Up @@ -511,6 +512,9 @@ describe('logged in boot', () => {
});
await con.getRepository(User).save({
...usersFixture[0],
subscriptionFlags: {
cycle: SubscriptionCycles.Yearly,
},
defaultFeedId: '1',
});
mockLoggedIn();
Expand All @@ -520,6 +524,24 @@ describe('logged in boot', () => {
.expect(200);
expect(res.body.user.defaultFeedId).toEqual('1');
});

it('should not return default feed id if not plus', async () => {
await con.getRepository(Feed).save({
id: '1',
name: 'My Feed',
userId: '1',
});
await con.getRepository(User).save({
...usersFixture[0],
defaultFeedId: '1',
});
mockLoggedIn();
const res = await request(app.server)
.get(BASE_PATH)
.set('Cookie', 'ory_kratos_session=value;')
.expect(200);
expect(res.body.user.defaultFeedId).toBeNull();
});
});

describe('boot marketing cta', () => {
Expand Down
133 changes: 127 additions & 6 deletions __tests__/feeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,23 @@ describe('query anonymousFeed', () => {
loggedUser = '1';

nock('http://localhost:6000')
.post('/popular', {
.post('/feed.json', {
total_pages: 1,
page_size: 10,
fresh_page_size: '4',
offset: 0,
user_id: '1',
source_types: ['machine', 'squad'],
allowed_languages: ['en'],
feed_config_name: 'popular',
min_day_range: 14,
allowed_content_curations: [
'news',
'release',
'opinion',
'comparison',
'story',
],
})
.reply(200, {
data: [{ post_id: 'p1' }, { post_id: 'p4' }],
Expand All @@ -454,7 +465,7 @@ describe('query anonymousFeed', () => {

it('should safetly handle a case where the feed is empty', async () => {
loggedUser = '1';
nock('http://localhost:6000').post('/popular').reply(200, {
nock('http://localhost:6000').post('/feed.json').reply(200, {
data: [],
});
const res = await client.query(QUERY, {
Expand Down Expand Up @@ -519,14 +530,25 @@ describe('query anonymousFeed', () => {
]);

nock('http://localhost:6000')
.post('/popular', {
.post('/feed.json', {
total_pages: 1,
page_size: 10,
fresh_page_size: '4',
offset: 0,
blocked_tags: ['python', 'java'],
blocked_sources: ['a', 'b'],
user_id: '1',
source_types: ['machine', 'squad'],
allowed_languages: ['en'],
feed_config_name: 'popular',
min_day_range: 14,
allowed_content_curations: [
'news',
'release',
'opinion',
'comparison',
'story',
],
})
.reply(200, {
data: [{ post_id: 'p1' }, { post_id: 'p4' }],
Expand Down Expand Up @@ -3289,13 +3311,14 @@ describe('query feedPreview', () => {
loggedUser = '1';

nock('http://localhost:6000')
.post('/popular', {
.post('/feed.json', {
user_id: '1',
page_size: 20,
offset: 0,
total_pages: 1,
fresh_page_size: '7',
allowed_tags: ['javascript', 'webdev'],
feed_config_name: 'popular',
})
.reply(200, {
data: [{ post_id: 'p1' }, { post_id: 'p4' }],
Expand Down Expand Up @@ -4292,6 +4315,24 @@ describe('query customFeed', () => {
},
},
]);
await con.getRepository(ContentPreferenceUser).save([
{
feedId: 'cf1',
referenceUserId: '2',
referenceId: '2',
status: ContentPreferenceStatus.Follow,
userId: '1',
},
]);
await con.getRepository(ContentPreferenceSource).save([
{
feedId: 'cf1',
sourceId: 'a',
referenceId: 'a',
status: ContentPreferenceStatus.Follow,
userId: '1',
},
]);
await con.getRepository(ContentPreferenceKeyword).save([
{
feedId: 'cf1',
Expand Down Expand Up @@ -4339,6 +4380,26 @@ describe('query customFeed', () => {

it('should return the feed by slug', async () => {
loggedUser = '1';
isPlus = true;

nock('http://localhost:6000')
.post('/feed.json', {
user_id: '1',
page_size: 10,
offset: 0,
total_pages: 1,
fresh_page_size: '4',
allowed_tags: ['webdev', 'html', 'data'],
allowed_sources: ['a'],
allowed_author_ids: ['2'],
feed_config_name: FeedConfigName.CustomFeedV1,
disable_engagement_filter: false,
})
.reply(200, {
data: [{ post_id: 'p1' }, { post_id: 'p4' }],
cursor: 'b',
});

const res = await client.query(QUERY, {
variables: {
ranking: Ranking.POPULARITY,
Expand Down Expand Up @@ -4379,6 +4440,25 @@ describe('query customFeed', () => {

it('should return feed with preconfigured filters', async () => {
loggedUser = '1';
isPlus = true;

nock('http://localhost:6000')
.post('/feed.json', {
user_id: '1',
page_size: 10,
offset: 0,
total_pages: 1,
fresh_page_size: '4',
allowed_tags: ['webdev', 'html', 'data'],
allowed_sources: ['a'],
allowed_author_ids: ['2'],
feed_config_name: FeedConfigName.CustomFeedV1,
disable_engagement_filter: false,
})
.reply(200, {
data: [{ post_id: 'p1' }, { post_id: 'p4' }],
cursor: 'b',
});

const res = await client.query(QUERY, {
variables: {
Expand All @@ -4390,12 +4470,33 @@ describe('query customFeed', () => {

expect(res.errors).toBeFalsy();
expect(res.data.customFeed.edges.map((item) => item.node.id)).toMatchObject(
['p5', 'p4', 'p1'],
['p1', 'p4'],
);
});

it('should not return posts with blocked tags', async () => {
loggedUser = '1';
isPlus = true;

nock('http://localhost:6000')
.post('/feed.json', {
user_id: '1',
page_size: 10,
offset: 0,
total_pages: 1,
fresh_page_size: '4',
allowed_tags: ['html', 'data'],
blocked_tags: ['webdev'],
allowed_sources: ['a'],
allowed_author_ids: ['2'],
feed_config_name: FeedConfigName.CustomFeedV1,
disable_engagement_filter: false,
})
.reply(200, {
data: [{ post_id: 'p4' }],
cursor: 'b',
});

await con.getRepository(ContentPreferenceKeyword).save([
{
feedId: 'cf1',
Expand All @@ -4417,12 +4518,13 @@ describe('query customFeed', () => {

expect(res.errors).toBeFalsy();
expect(res.data.customFeed.edges.map((item) => item.node.id)).toMatchObject(
['p5', 'p4'],
['p4'],
);
});

it('should return v2 feed', async () => {
loggedUser = '1';
isPlus = true;

nock('http://localhost:6000')
.post('/feed.json', {
Expand All @@ -4432,6 +4534,8 @@ describe('query customFeed', () => {
total_pages: 1,
fresh_page_size: '4',
allowed_tags: ['webdev', 'html', 'data'],
allowed_sources: ['a'],
allowed_author_ids: ['2'],
feed_config_name: FeedConfigName.CustomFeedV1,
disable_engagement_filter: false,
})
Expand All @@ -4452,4 +4556,21 @@ describe('query customFeed', () => {
['p1', 'p4'],
);
});

it('should not return the feed by slug if not plus', async () => {
loggedUser = '1';

await testQueryErrorCode(
client,
{
query: QUERY,
variables: {
ranking: Ranking.POPULARITY,
first: 10,
feedId: 'cool-feed-cf1',
},
},
'FORBIDDEN',
);
});
});
2 changes: 1 addition & 1 deletion seeds/Post.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ export const ONE_DAY_IN_SECONDS = ONE_HOUR_IN_SECONDS * 24;
export const ONE_WEEK_IN_SECONDS = ONE_DAY_IN_SECONDS * 7;

export const MAX_FOLLOWERS_LIMIT = 5_000;

export const customFeedsPlusDate = new Date('2024-12-11');
Loading

0 comments on commit a049567

Please sign in to comment.