promotably / api

API service
Eclipse Public License 1.0
0 stars 1 forks source link

Deleted flag required for metrics offers and promos #210

Closed tomsouthall-zz closed 9 years ago

tomsouthall-zz commented 9 years ago

When I list the promos and offers on the metrics page, I provide a link allowing the user to quickly access the corresponding edit screen (see screenshot).

image

However, if the promo or offer happens to be deleted, I should not be creating the link. However I currently do as I have no way to know if the promo/offer is deleted, and following it results in a 500 error.

I need a deleted flag to be added to any entity in the response that has been deleted.

e.g.

{
  "code": "DISCOUNT-10",
  "discount": 6.7,
  "id": "d2cf4d3c-636c-4816-96cc-ef924a1fccd6",
  "redemptions": 3,
  "revenue": 83.5,
  "revenue-per-order": 27,
  "deleted": true
}

If the entity is not deleted, the flag can either be set to false or simply not be present. Either is fine.

cvillecsteele commented 9 years ago

I don't think this is an MVP bug.

tomsouthall-zz commented 9 years ago

Problem is that links for anything that gets deleted are currently broken and cause errors, so we either need to add the flag or not display the links at all. Or I could catch the error and display some sort of message - but that's a lot more work than what I proposed so would rather not.

cvillecsteele commented 9 years ago

Right now if the user delete something it's gone, removed from the database. We can come back around and change that behavior later, but for MVP, I think the corresponding offer/promo should be just removed from the UI if the user deletes it. Gone is gone, currently.

tomsouthall-zz commented 9 years ago

OK that works. A change is needed then on both end-points to filter out deleted promos and rcos.

bpromo commented 9 years ago

I can take this one but are we sure we wouldn't rather undo the delete function and make it more of a disable in the DB?

cvillecsteele commented 9 years ago

@bpromo Where do we stand on this issue?

bpromo commented 9 years ago

Oooh this fell off my radar. Haven't looked at it at all. Thanks for reminding me.

So to implement as it stands I need to check the list produced for metrics/rco and metrics/promos against the database to see if they exists anymore and then set the deleted flag appropriately.

Should be able to wrap this up tomorrow. If the above is incorrect please let me know.

We are going to want to remove the hard delete feature. Could make analytics and machine learning a lot more tricky if records disappear underneath us over time.