I'm planing the migration of our  app to HRD. It is a "collective buying" 
site, and found lots of places where I need to change my models/queries. In 
fact, some cases where we need consistency is this scenario:

class Product {
  @Id Long productId;
}
class Order {
   @Id Long orderId;
   List<Long> productId;
}
class Voucher {
   @Id Long voucherId;
   Long orderId;
   Long productId;
}

Vouchers must be created before orders, so they are currently root entities. 
When an order is approved, I have a specialized queue with 
max_concurrent_request = 1 that picks the next available voucher (with has 
orderId = null) and associates it with an order. To check if the order is 
filled with all it's vouchers, I "count" how many Vouchers are linked with 
that orderId, and if there is Vouchers missing, I schedule another queue to 
consume a Voucher again.

On HRD, this don't work because my the query to get the next Voucher and the 
query to check how much vouchers I have for an Order is more likelly to 
don't be consistent. What I'm planning to perform is to group Vouchers that 
are from the same "product" (~ 30k vouchers per product) and then perform 
the ancestor query, as suggested by the docs. In this case, I'll end up 
with:

class Voucher {
   @Parent Key<Procut> productId;
   @Id Long voucherId;
   Long orderId;
}

... and will be able to query for how many Vouchers are linked to an order 
(one query for each of items in Order.productId). Is this a good pattern for 
this particular scenario? The writes/second is not a problem for us: i.e. if 
the order stays for a few minutes until the Vouchers are all filled, it is 
ok.

Another issue: I have to perform some financial accounting registry, and 
currently I have this entity:

class AccountingRegistry {
   @Parent Key<AccountRegistry> parentRegistry;
   @Id Long id;
   Date date;
   Long ammount;
   List<String> filters;
}

To represent an accounting transaction, I'm grouping in the same entity 
group all registry that are related, and that summed up equals 0. To avoid 
performing the same transaction twice (i.e., register twice the same order 
approval), I'm using the "filters" list property to query for another 
registry that has the same filters (i.e. the order id, the "APROVED" 
keyword, the domain, etc.). They are also usefull to have some specialized 
reports, like all sales that came from this domain (domain is one value for 
the list property). On M/S, as Jeff said, the time window is small, and the 
chance to have a problem is small, but on HRD the window may take several 
minutes, and in this case I may have a very inconsistent sales report at the 
end of the day.

Does you guys think that I can use the same pattern Jeff suggested to solve 
this problem? Any advice?

Thanks in advance

- Ronoaldo

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/QC0MbTJiIwUJ.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to