Skip to content

Results are not idem-potents #20

@pcorbel

Description

@pcorbel

Expected Behavior

When using the client, I should be able to have idem-potent results when iterating over campaign_results by campaign_id

Current Behavior

Results are different if I fetch campaign_results from campaign 123, then 456, then 789 from when I fetch campaign_results from 789, then 456, then 123.

Possible Solution

I have to "refresh" my client by calling api = ub.APIClient("xxx", "xxx") at each run

Steps to Reproduce

import usabilla as ub

api = ub.APIClient("xxx", "xxx")

# This order won't give the same results as 
# for campaign in ["123", "456", "789", "foo"]:
# This order
for campaign in ["foo", "123", "456", "789"]:
	# If I refresh the client here, it works 
    # api = ub.APIClient("xxx", "xxx")
    responses = api.get_resource(
        api.SCOPE_LIVE,
        api.PRODUCT_WEBSITES,
        api.RESOURCE_CAMPAIGN_RESULT,
        campaign,
        iterate=True,
    )
    count = 0
    for response in responses:
        count = count + 1

    print(f"{campaign} {count}")

Results for first order:

campaign_id count
123 1593
456 0
789 77
foo 0

Results for another order:

campaign_id count
foo 23
123 14
456 0
789 77

Results when I refresh the client (good results):

campaign_id count
foo 23
123 1593
456 130
789 77

Context (Environment)

Docker image: python:3.7.4
Python lib: usabilla-api==2.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions