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

Multiple Gimmicks #6

Open
gordonjb opened this issue Apr 17, 2019 · 8 comments
Open

Multiple Gimmicks #6

gordonjb opened this issue Apr 17, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@gordonjb
Copy link
Owner

Figure out how to deal with duplicates.

Currently any duplicate workers, shows, or promotions are skipped. For workers, we really want to check if their ID exists, and if it does, append the gimmick name to the "name" field if it's not already in there. This could be a "nice to have" though.

@gordonjb
Copy link
Owner Author

Some test SQL to try:

SELECT * FROM workers;

INSERT OR IGNORE INTO workers(worker_id, name)
                 VALUES(1234,"Elizabeth")
                 
INSERT OR IGNORE INTO workers(worker_id, name)
                 VALUES(1234,"Laura Di Matteo");
                 
INSERT OR IGNORE INTO workers(worker_id, name)
                 VALUES(1234,"Laura Di Matteo");
                 
INSERT OR IGNORE INTO workers(worker_id, name)
                 VALUES(1234,"Vegan Moth");
                 
INSERT OR IGNORE INTO workers(worker_id, name)
                 VALUES(1234,"Laura Di Matteo");
                 
SELECT * FROM workers;

INSERT INTO workers(worker_id, name)
  VALUES(1234,"Laura Di Matteo")
  ON CONFLICT(worker_id) DO UPDATE SET name=name + "/" + excluded.name;
                 
INSERT INTO workers(worker_id, name)
  VALUES(1234,"Laura Di Matteo")
  ON CONFLICT(worker_id) DO UPDATE SET name=name + "/" + excluded.name;
                 
INSERT INTO workers(worker_id, name)
  VALUES(1234,"Vegan Moth")
  ON CONFLICT(worker_id) DO UPDATE SET name=name + "/" + excluded.name;
                 
INSERT INTO workers(worker_id, name)
  VALUES(1234,"Laura Di Matteo")
  ON CONFLICT(worker_id) DO UPDATE SET name=name + "/" + excluded.name;
  
SELECT * FROM workers;

This possible solution starter uses SQLite's new(ish) UPSERT, added as of 3.24.0 (2018-06-04)

@gordonjb
Copy link
Owner Author

Never mind, none of the tooling (sqlite3 or sqlitebrowser) support UPSERT 🙄

Going to try some if/elses

@gordonjb
Copy link
Owner Author

gordonjb commented Apr 23, 2019

OK, this seems to work as a starter for 10:

UPDATE workers
SET name = "Vegan Moth" || "/" || name
WHERE workers.worker_id == 1234 AND instr(name, "Vegan Moth") == 0

Need to figure out how do do this conditionally if a record already exists and insert if not. Simplest simplest way is probably to just avoid doing it in SQL and do a separate test for existance in the Python and then let python decide wether to call for an INSERT or an UPDATE.

@gordonjb
Copy link
Owner Author

Just realised this wouldn't work for, for instance, if we had a "Ray Rowe" entry, and tried to add the ring name "Rowe", this wouldn't be added.

I was also thinking it would be nice if the most used name was at the front. That would be much more complicated though...

@gordonjb gordonjb added the enhancement New feature or request label Jun 14, 2019
@gordonjb
Copy link
Owner Author

#6 (comment) isn't going to work either, it's just going to keep adding names to the name every time there's an appearance 🤣

@gordonjb
Copy link
Owner Author

Maybe the naming burden should be put into appearances? We could then do things like names in order of most used, just have the workers table be IDs

At that point is it worth having at all

who'd be a dba

@gordonjb
Copy link
Owner Author

OK, maybe the thing to do is request the worker page, and grab the current name from there and just use that. We could also grab AKAs from there. Or any other info we want in future

@gordonjb
Copy link
Owner Author

AKAs could go in a separate field, and we could apply them just from appearances! If the text name does not match the field name, add to AKA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant