Matthew
19.12.2017
16:27:39
That's a good way of doing it
My query-per-product method takes 9 seconds, so I will optimise with your code :)
Andrew
19.12.2017
16:31:41
Has anyone seen this error before:
'''
pony.orm.dbapiprovider.OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
'''
Im seeing it in a production build, and Im at a lose for what the deal is.
Google
Andrew
19.12.2017
16:34:33
Not sure if its pony, or if its postgres issue.
I would assume the latter
Alexander
19.12.2017
16:35:21
It will be easier to tell the answer if you post full traceback. I need to go offline for a hour, and then I can tell what is the reason for the error
You can message traceback directly to me, if you want
Andrew
19.12.2017
16:36:27
Matthew
20.12.2017
13:43:50
At this moment Pony does not support nested tables as a query result. Not all databases allow them. I think it is not necessary to calculate all these information inside a single query, it can be split to two different query with roughly the same total performance. So, instead of:
products = select(
(p, count(p.reviews), select(
(r.review_rating, models.count())
for r in models.Review if r.product == p))
for p in ReviewProduct if JOIN(User[1] in p.users))
You can write two queries, convert them to dict in Python and then combine these dicts if you wish to do it:
query1 = select(
(p, count(p.reviews))
for p in ReviewProduct
if JOIN(User[1] in p.users)
)
review_counts = {
product: review_count for product, review_count in query1
}
query2 = select(
(r.product, r.review_rating, models.count())
for r in Review
if JOIN(User[1] in r.product.users))
rating_counts = defaultdict(dict)
for product, review_raiting, review_count in query2:
rating_counts[product][review_raiting] = review_count
Turns out that I could just use query2 and then sum its results in a loop, removing the need for query 1 :)
it's fast now
product_score_counts = collections.defaultdict(dict)
for _ in models.select((r.product, r.review_rating, models.count()) for r in models.Review
if models.JOIN(current_user_object() in r.product.users)):
product_score_counts[_[0]][_[1]] = _[2]
products = sorted([(k, sum(v.values())) for k, v in product_score_counts.items()], key=lambda _: _[1], reverse=True)
Adam
21.12.2017
02:23:56
Hello im having problems with sqlite:
TransactionIntegrityError: Object Autodelete[new:92] cannot be stored in the database. IntegrityError: FOREIGN KEY constraint failed
stsouko
21.12.2017
06:00:55
Adam
21.12.2017
06:02:05
sorry kinda new to this .. so not sure what you mean
stsouko
21.12.2017
06:04:34
Are you using multiprocessing?
Adam
21.12.2017
06:05:05
asyncio
Google
stsouko
21.12.2017
06:12:45
For except this errors storing to db I do in single thread
Adam
21.12.2017
06:35:42
maybe not the most cleanest but i figured out a way but just doing a forced commit
Alexander
21.12.2017
08:38:44
Farid
24.12.2017
14:06:02
does ponyorm have support for mptt algorithm?
Matthew
24.12.2017
14:09:02
start a group for Russian and kick the bots
Farid
24.12.2017
14:28:56
how do you manage trees on ponyorm?
Alexander
24.12.2017
14:32:28
Which trees?
Farid
24.12.2017
14:33:31
graphs
for example in django orm they have django-mptt for maintaining trees.
https://github.com/django-mptt/django-mptt
Alexander
24.12.2017
14:37:32
As I know pony doesn't have anything about storing trees implemented.
I'm not sure but you can store tree as a JSON, probaly.
You can wait for pony author which is offline right now, he might give you some efficient suggesttions.
Alexander
24.12.2017
20:47:21
I think bots are a bit noisy :)
Hi Farid, at this moment PonyORM does not have special support for maintaining trees, you need to do it manually. In the future I want to add support for hierarchical structures, but probably not too soon
Luckydonald
26.12.2017
11:41:27
Why that?
Why that?
It was mainly in here for the permalink feature.
If the rest of the bot was to noisy, how about @PermalinkBot?
It serves just the github permalink feature.
Alexander
26.12.2017
11:56:18
I got the impression that the permalink feature at the moment is not too much in demand by users
I still don't get the meaning of the bot
+1
Also, when someone post a link to github repository, typically it is not for specific commit, so when a bot post a message after each link it looks a bit like a spam
Perhaps we can add it again in the future, if users ask about it
Google
Luckydonald
27.12.2017
01:45:52
@bonbot had more features, so user tried them out.
But this bot only acts on links of files on github, and that's all.
I don't really think it spams, as it makes github links future-proof, adding just a single line.
If you try to access a link later it's always work to find the right commit, at the right day.
Alexander
27.12.2017
13:47:31
Ok, sounds good
Luckydonald
27.12.2017
17:19:22
Sorry, you meant to add @PermalinkBot.
@bonbot is the spammy multi-purpose bot.
My mistake. I was not clear above. Sorry. @PermalinkBot it is.
Alexander
27.12.2017
17:21:01
No problem )