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

Build relational table functions #15

Open
Operator873 opened this issue Jan 27, 2022 · 2 comments
Open

Build relational table functions #15

Operator873 opened this issue Jan 27, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request major This issue requires a significant change SQL This change involved writing sql

Comments

@Operator873
Copy link
Owner

New tables 'people' and 'channels' are created for relational support. Add populating sql commands to add to and delete from these tables on !watch add and !watch del respectively. !globalwatch should also write to these tables, but in people table, project should be global and no difference to the channels table.

Table: people
Columns

  • nick
  • project

Table channels
Columns

  • channel
  • nick
@Operator873 Operator873 added enhancement New feature or request SQL This change involved writing sql labels Jan 27, 2022
@Operator873
Copy link
Owner Author

    if (
        len(
            c.execute(
                '''SELECT * FROM %s WHERE nick="%s";''' % (project, nick)
            ).fetchall()
        ) == 0
    ):
        c.execute('''DELETE FROM people WHERE nick=? AND project=?;''', (nick, project))
        db.commit()

This is a good example of how to do the check, but this will take more thinking. Pseudo code follows:

!watch del ptwiki SomePage

check if following that page in that project table
   if yes
      delete from project table
      commit change

   check nick in has other watched pages in project
      if no
         delete from people (nick, project)
         commit change

   select projects nick is following
      for proj in projects
         check to see if nick has watched pages on that proj in this channel
         if no
             delete from channels table

@Operator873
Copy link
Owner Author

Might be best to do this whole process in a separate function.

def synctables(project, chan, nick, action=add/del/etc)??

@Operator873 Operator873 self-assigned this Feb 19, 2022
@Operator873 Operator873 added the major This issue requires a significant change label Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request major This issue requires a significant change SQL This change involved writing sql
Projects
None yet
Development

No branches or pull requests

1 participant