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

Used tracdb instead of Trac RPC endpoint in dashboard #1479

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

bmispelon
Copy link
Member

Hi,

For some context, I've been working on code.djangoproject.com recently and I would like to propose removing the API page at code.djangoproject.com/rpc. However it was pointed out to me that dashboard.djangoproject.com actually uses that API to gather some of its statistics.

So my initial goal was to rewrite the dashboard metrics to make use of the tracdb models instead.

I wanted to have a few tests to make sure I wasn't breaking everything, which is why this PR got slightly out of hand. It turned out that testing those unmanaged tracdb models was more of a challenge than I'd anticipated but I think I landed on something somewhat readable (and hopefully not too horrible) in the end.

A nice side-effect is that this PR removes the need for two of the database views (which are a maintenance burden and caused us some downtime a few weeks ago after an upgrade).

@bmispelon bmispelon force-pushed the dashboard-tracdb-instead-of-api branch 5 times, most recently from b03c112 to 310a133 Compare February 12, 2024 23:14
@sabderemane sabderemane self-requested a review February 27, 2024 01:10
@sabderemane
Copy link
Member

Hey @bmispelon , I have started to look at it, looks good to me, I have to reinstall the project (don't ask me why) and I will review it fully then.
This PR is not linked to the upgrade of djangoproject.com. right? Could it be merge before or does it seems a bad idea?

@bmispelon
Copy link
Member Author

Hi Sarah and thanks for taking a look!

This PR is independent from the one about upgrading Django and could absolutely be merged before. In fact, I'd like it to be deployed so I can remove some dependencies from code.djangoproject.com.

@bmispelon
Copy link
Member Author

@sabderemane have you had a chance to look at this? Is there something I can do to make the review easier?

Copy link
Member

@felixxm felixxm left a comment

Choose a reason for hiding this comment

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

@bmispelon Thanks 👍 Looks good 🚀 it's worth trying 🤞

Are we going to remove xmlrpcplugin from code.djangoproject.com?

@bmispelon
Copy link
Member Author

Thanks for the review! ✨

Are we going to remove xmlrpcplugin from code.djangoproject.com?

Eventually I would like to, yes (I don't trust that it's being maintained and I find it hard to audit what capabilities it actually gives, and how those capabilities interact with Trac's permissions).
I strongly suspect that the dashboard is the only real user of that API, but I could be wrong (I guess I now have all the access I need to be able to actually check that 👀 )

@bmispelon bmispelon force-pushed the dashboard-tracdb-instead-of-api branch from 6360563 to 30b196b Compare April 25, 2024 19:59
@bmispelon bmispelon merged commit 65320ed into django:main Apr 25, 2024
2 checks passed
Comment on lines +25 to +30
TicketCustom.objects.bulk_create(
[
TicketCustom(ticket=ticket, name=name, value=value)
for name, value in custom.items()
]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

@bmispelon I'm coming from #1792 (comment)

Model.objects.create(...) correctly creates the object in the db

This is not working with 5.1 🙁 I was trying to debug it, but I couldn't understand how did this work in the first place. We have TicketCustom.ticket.primary_key = True in place, and the docs say

primary_key=True implies null=False and unique=True.

So we shouldn't be able to create multiple TicketCustoms with the same ticket value in the first place (I guess) but somehow it was working fine.

Do you have any ideas about why would this work fine until now but start breaking with Django 5.1?

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.

4 participants