DDMAL / CantusDB

A new site for Cantus Database running under Django.
https://cantusdatabase.org
MIT License
5 stars 6 forks source link

When merging Indexers and Users from OldCantus, we should preserve original Indexer IDs rather than user IDs #714

Closed jacobdgm closed 1 year ago

jacobdgm commented 1 year ago

When we merged the indexer and user models last year, where a person had both an indexer object and a user account, we kept the existing user ID and added some indexer-relevant information to the user object, including the person's old ID as an indexer.

Since you can get to an Indexer detail page via a /node/ URL in OldCantus (see #563), we should renumber users so they are identified by their original Indexer ID.

jacobdgm commented 1 year ago

@PythonSemicolon: could we set up #563 do this without renumbering users? For the indexer check, we could just use User.objects.get(old_indexer_id=pk) rather than User.objects.get(id=pk), couldn't we?

jacobdgm commented 1 year ago

If we renumber users in this way, we should also set up a redirect in case someone tries to access a user page via the user's old ID. But this may not be necessary, if we adopt the approach to #563 outlined in my previous comment.

PythonSemicolon commented 1 year ago

@PythonSemicolon: could we set up #563 do this without renumbering users? For the indexer check, we could just use User.objects.get(old_indexer_id=pk) rather than User.objects.get(id=pk), couldn't we?

My initial though was that this couldn't work due to conflicts such as this and this sharing the same ID. However, in theory it should be possible since the conflicts only occur between NewCantus User IDs and OldCantus node IDs (meaning that as long as we don't search for the former, there can only ever be at most one match). In the case of the previously mentioned match, the ID from the /node/ path won't match any other nodes, we just have to look for it in the different attribute as mentioned. Will give this a go.

PythonSemicolon commented 1 year ago

The fix seems to work @jacobdgm! I begin by checking if there is a user whose old_indexer_id matches the node ID. If there is, that user's page is returned; otherwise, the other four tables (chant, source, sequence, article) are checked, and finally a 404 is returned following that.

jacobdgm commented 1 year ago

sounds great - much better than changing all our users' IDs!

Take note, @lucasmarchd01 - looks like we won't need to change this aspect of the data syncing process.

Thanks all around!

lucasmarchd01 commented 1 year ago

Sounds good, thanks!