DBRepair development

Gotcha. I don’t play with the DB directly myself because that’s just not in my tech toolbox so I appreciate the clarification.

I have every user I ever granted access to my server showing up in the new dashboard on new mobile apps. Accounts I removed several years ago are now showing up. They do not show up in WebUI dashboard or the “legacy” Plex Dash. These old accounts showing up again is what had me coming to forums to find out how to clean up or if it was a bug and finding Chuck had just added the “expunge” command to this tool and was testing it. Serendipity! :slight_smile:
Chuck confirmed after testing and not getting that result though that “expunge” removes user\history specifically if they no longer have a Plex account.

I had thought that removing the user from my server also removed their data from my server but that was my misunderstanding. I just didn’t see it anymore. I can understand why Plex would hold it for a time (removed a user, but it was an accident or they changed their mind).

I think it’d be useful for Plex to have a way to clean that up just for “cleanliness” sake, but functionally I just don’t wanna weed through unnecessary user data in the dashboard so maybe that’s outside this tool project and I just need to put in a feature request for the new dashboard. :slight_smile:

Are you saying that running the expurge didn’t help, since that would indicate they still are in the accounts table?

@dane22 - Correct. That aspect is likely buried in earlier comments about it a couple weeks ago so I wasn’t as complete about it in these additional comments which might’ve been less clear than it could have been; sorry.

If the accounts table is a record of accounts connected to your local server, then expurge is not referencing that table; as far as I understand. ChuckPa mentioned in those earlier comments that expurge is checking account active\inactive via Plex online account status, not referencing the local server. So, it won’t remove an inactive account from your local server unless the user deleted their Plex account entirely.

I had assumed it would remove inactive accounts - user accounts that I removed from sharing access - but that was an incorrect assumption. That’s why in follow ups I recommended changing the wording of the command to be more specific about it removing inactive “Plex Accounts” not inactive “User Accounts” in case others had the same incorrect expectation.

I can see an argument for both sides of keep\delete as part of clean-up or historical reference. For me it is just that I don’t want to see inactive users from years ago in the dashboard and up until the new mobile app incorporated the dashboard I didn’t see them. Now I do. I don’t wanna. Either I want to be able to hide them again, or be able to remove them - but I can see how my preference might not be everyone’s preference.

Sorry for the long text details (some repeats of earlier info) about it here - kinda tangent to usual DBRepair stuff.

It’s the other way.

I only look at the local database (PMS is shutdown and DBRepair does not have your Plex credentials to talk to Plex.tv as that would be out of scope)

Well, you could do this:

  • Shut down PMS
  • Make a backup copy of your databae
  • Open the database with something like https://sqlitebrowser.org/dl/
  • Select the offending account in the accounts table and delete it
  • Run DBRepair afterwards with option expurge

Your issue should then be fixed, and should something go wrong, simply replace the database with the backup

At this point I am confused.

Can you maybe explain in now detail what this feature is actually doing? If you find the time :smiley:

Simply this: if I remove a user from accessing my server, but his history is still living in my database, will this feature remove that history from my database?

I specifically remove the records for orphaned (Deleted) accounts.

It sounds like the request is to delete more (which I’ve missed somehow).

Can I please have the request again with knowledge that I don’t talk to Plex.tv in DBRepair ?

May I request someone send me the “Plex SQLite” output from querying the main ‘com.plexapp.plugins.library.db’ ?

Specific queries to run and send me:

SELECT 
  id, 
  name, 
  datetime(created_at, 'unixepoch', 'localtime') AS created, 
  datetime(updated_at, 'unixepoch', 'localtime') AS updated 
FROM accounts;
SELECT 
  account_id, 
  COUNT(*) AS items_with_status, 
  SUM(view_count) AS total_plays,
  datetime(MAX(last_viewed_at), 'unixepoch', 'localtime') AS last_active
FROM metadata_item_settings 
WHERE account_id > 1 
GROUP BY account_id;
SELECT 
  account_id, 
  COUNT(*) AS timeline_events, 
  datetime(MAX(viewed_at), 'unixepoch', 'localtime') AS last_event
FROM metadata_item_views 
WHERE account_id > 1 
GROUP BY account_id;
SELECT 
  COUNT(*) AS orphaned_settings 
FROM metadata_item_settings 
WHERE account_id NOT IN (SELECT id FROM accounts);

SELECT 
  COUNT(*) AS orphaned_views 
FROM metadata_item_views 
WHERE account_id NOT IN (SELECT id FROM accounts);

These queries will show me what I’m missing.
( I don’t share my server with anyone so I don’t have the data)

@Insomnic_1 @d2freak

Can you please run the above queries for me?

If you can include, in the PM, which names/records should be removed and why, that’ll really help.

I could… but I really hate fiddling with raw databases. I can do it but it’s always been an awkward thing for me to do so I’ve always avoid it for fear I’ll mess something up unintentionally.
So far this isn’t a big enough deal to overcome that awkwardness. :slight_smile:

Yah. Me too. I’m sure it’s just a miscommunication of dev vs user expectations about terminology. :slight_smile:

So as an example.
I share my Plex server with Jim. Jim eventually stops using my Plex server because he just likes using Netflix. I remove Jim from my Plex server.
The assumption, based on experience up to now, was that the data was removed because it wasn’t visible in GUI.
But in reality, the records for Jim still exists as revealed by the new dashboard on mobile devices.
I was hoping “expunge” would remove that user and their records. It doesn’t.

What is a “deleted” account? I get the feeling that terminology is not lining up between devs and users here is all and that’s what may be unintentionally causing miscommunication. I thought removing “Jim” from access was deleting the from my server but that isn’t accurate because according to the mobile dashboard all the “removed” users still existed, they just weren’t displayed anymore - at least that is the experience.

Err… we’re back to the “awkward” stage I mentioned but I’ll give it a shot in the next day or two. :slight_smile:
Can I use the https://sqlitebrowser.org/dl/ app to run those commands (looks like it should)? I’m using Mac these days and I see they have a version that I can grab and docs that are easy to follow. If not that app I’ll dig up something else. I’ve run SQL functions before but as I said it’s a weird blind spot for me as a “techie” (particularly as I’ve not done it in years now) but I can follow instructions just fine (thank you for being so explicit).

Thanks!

@ChuckPa AFAIK, Plex does not remove old accounts from the database even if you stop sharing it even if that account no longer exists. There isn’t any mechanism I’veseen that will remove a user from the database, so you would need to add a feature to allow the admin to remove the user from the accounts table, then the play history could get removed.

@MovieFan

That’s why I’ve asked for the queries I did.

Just as with with old temp file removal, it should be possible to remove play history & accounts with no activity after X days . This means you can remove someone’s access and then the account ages out and disappears

(that’s my thinking)