Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Campaigns & Leads #400

Merged
merged 5 commits into from
Oct 28, 2021
Merged

Campaigns & Leads #400

merged 5 commits into from
Oct 28, 2021

Conversation

cassidysymons
Copy link
Collaborator

No description provided.

microsetta_private_api/api/_campaign.py Show resolved Hide resolved
longitude double precision,
confirm_consent boolean DEFAULT FALSE,
ip_address varchar,
creation_timestamp timestamp DEFAULT NOW(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
creation_timestamp timestamp DEFAULT NOW(),
creation_timestamp timestamp not null DEFAULT NOW(),

Comment on lines 34 to 36
address_checked boolean DEFAULT FALSE,
address_valid boolean DEFAULT FALSE,
converted_to_account boolean DEFAULT FALSE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
address_checked boolean DEFAULT FALSE,
address_valid boolean DEFAULT FALSE,
converted_to_account boolean DEFAULT FALSE,
address_checked boolean not null DEFAULT FALSE,
address_valid boolean not null DEFAULT FALSE,
converted_to_account boolean not null DEFAULT FALSE,

country varchar,
latitude double precision,
longitude double precision,
confirm_consent boolean DEFAULT FALSE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
confirm_consent boolean DEFAULT FALSE,
confirm_consent boolean not null DEFAULT FALSE,

properties:
'campaign_id':
type: string
'title':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these are required fields, and if not provided, will result in a 500 error. Can the required fields be noted? see the endpoint associated with microsetta_private_api.api.create_human_source_from_consent as an example

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking at it, the only field that's globally required - and therefore can be in the API as such - is title. campaign_id is only required on updates and associated_projects is only required on creation. I could break it into two separate api paths if you prefer, but that might be overkill.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more consistent w/ the rest of the API for creation to be POST and update to be PUT, but against the same endpoint. Does that make sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, will adjust in a few minutes.

Comment on lines 94 to 100
for project_id in projects:
cur.execute(
"INSERT INTO barcodes.campaigns_projects ("
"campaign_id,project_id"
") VALUES (%s, %s) ",
(campaign_id, project_id)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for project_id in projects:
cur.execute(
"INSERT INTO barcodes.campaigns_projects ("
"campaign_id,project_id"
") VALUES (%s, %s) ",
(campaign_id, project_id)
)
cur.executemany(
"INSERT INTO barcodes.campaigns_projects ("
"campaign_id,project_id"
") VALUES (%s, %s) ",
[(campaign_id, pid) for pid in projects]
)

# required parameters to update a campaign
campaign_id = kwargs['campaign_id']
title = kwargs['title']

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if 'associated_projects' in kwargs:
raise RepoException("Modification of associated projects not allowed")

campaign_repo = CampaignRepo(t)
with self.assertRaises(KeyError):
campaign_repo.create_campaign(**campaign_no_projects)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could a test be added to assert behavior with an unknown project ID (e.g., -1)?

with Transaction() as t:
duplicate_campaign = {
"title": "Test Campaign",
"associated_projects": "1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project IDs are all integer, do they actually come over the wire as string?

application/json:
schema:
type: object
'404':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the 404 be removed?

@wasade
Copy link
Member

wasade commented Oct 26, 2021 via email

@wasade wasade merged commit bfca3dd into master Oct 28, 2021
@cassidysymons cassidysymons deleted the csymons_campaigns branch June 29, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants