Skip to content

Commit

Permalink
Fix member control
Browse files Browse the repository at this point in the history
  • Loading branch information
kanehekili committed Feb 24, 2024
1 parent b7417ce commit dee4280
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 41 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.project
/.settings
/.pydevproject
/*.csv
/maria.txt
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ backup.sh will call sync.sh triggered by the backup systemd service which is tri

## TsvDBCreator
The database module. Uses mysqlconnection and has been tested with mariadb. Offers dabasebase setup and control via the DBTools.py, which is the interface to the underlying database system. <br />
In addition the creator provides email-tools and scripts for merging "Conplan" data into the intrinsic database.
In addition the creator provides email-integration and configuration of the access point.
It needs to be executed via terminal and provides a simple interface to configure the mail credentials as well as defining the individual access points:
* python TsvDBCreator -l - will save the code you changed in method "_fillLocationTable" into the db.
* python TsvDBCreator -t - will read rfid ids from an external file and saves them into the db.

## DBTools
Technical database abstraction for the mysql.connector. This is the place to change the database backend
Expand All @@ -112,7 +115,7 @@ Technical database abstraction for the mysql.connector. This is the place to cha
In order to import data from a retro software that is not able to provide any REST bindings, Ximporter has been created. It reads a propriaty XLS file and imports it into our system. Select a xls file (this feature needs to be adapted to the provider) to import it into the database. <br />
Due to some restraints on the given infrastructure - this code works on windows.. (but looks a lot uglier)

Ximporter has been written for "Conplan" and will have to be adapted for other backends.
Ximporter has been written for "Conplan" and will have to be adapted for other backends.Surprisingly it runs on windows and it is used to sync the member software with the TSVAccess database

![Screenshot](https://github.com/kanehekili/TSVAccess/blob/main/Ximporter.png)

Expand Down
2 changes: 1 addition & 1 deletion src/DBTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def deleteEntry(self,table,fn,condition):

def select(self,stmt):
try:
Log.debug(stmt)
Log.info(stmt)
with self._getCursor() as cursor:
cursor.execute(stmt)
return cursor.fetchall()
Expand Down
5 changes: 4 additions & 1 deletion src/RegModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ def getMembers(self):
#used by memberControl
def todaysAccessDateStrings(self, mbrID, activity):
table = self.dbSystem.TIMETABLE
stmt= "select access_date from %s where mitglied_id =%d and activity='%s' and DATE(access_date) = CURDATE();"%(table,mbrID,activity)
daysplit="13" #see TsvAuswertung
partDay = "((HOUR(access_date) < " + daysplit + " AND HOUR(CURTIME()) < " + daysplit + ") OR (HOUR(access_date) >= " + daysplit + " AND HOUR(CURTIME()) >= " + daysplit + "))"
#stmt= "select access_date from %s where mitglied_id =%d and activity='%s' and DATE(access_date) = CURDATE();"%(table,mbrID,activity)
stmt= "select access_date from %s where mitglied_id =%d and activity='%s' and DATE(access_date) = CURDATE() AND %s"%(table,mbrID,activity,partDay)
rows = self.db.select(stmt)
timeData=[]
for row in rows:
Expand Down
44 changes: 7 additions & 37 deletions src/TsvDBCreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,36 +283,6 @@ def defineDatabases(self):
self.db.createTable(self.TABLE8)
self.db.close()

def DEPRECATED_fillLocationTable(self):
#list the correlations:
#select host_name,room,activity,paySection,groups from Location loc JOIN Konfig conf where loc.config_id=conf.config_id;
#TODO update: one room can have 2 activities at the same time. Table needs -weekday -start-end...
#No start-end at location = always
#At a location we may have many activities
#modeshared=TsvAccess starts daemon. Replace with time schedule! So Locationtable may have more than one config!
self.db.createTable(self.TABLE4)
self.db.createTable(self.TABLE5)

table=self.CONFIGTABLE
fields = ('config_id', 'room', 'activity',"paySection","groups", "grace_time","mode")
entries=[]
entries.append((0,LOC_KRAFTRAUM,ACTIVITY_KR,SECTION_FIT, "['KR','ÜL']",900,0))
entries.append((1,LOC_SPIEGELSAAL,ACTIVITY_GYM,SECTION_FIT, "['KR','ÜL','FFA','GROUP']",3600,0))
entries.append((2,LOC_NORD,ACTIVITY_GYM,SECTION_FIT, "['KR','ÜL','FFA','GROUP']",3600,0))
entries.append((3,LOC_SAUNA,ACTIVITY_SAUNA,SECTION_SAUNA,"[]",3600*4,0)) #Login every 4 hours, no logout
self.db.insertMany(table, fields, entries)

table = self.LOCATIONTABLE
fields = ('host_name', 'config_id')
entries=[]
entries.append(("tsvaccess1",0))
entries.append(("tsvaccess2",3))
entries.append(("tsvaccess3",1))
entries.append(("tsvaccess4",2))
entries.append(("msi",0))
self.db.insertMany(table, fields, entries)


def _fillLocationTable(self):
#list the correlations:
#select host_name,room,activity,paySection,groups from Location loc JOIN Konfig conf where loc.config_id=conf.config_id;
Expand All @@ -338,14 +308,14 @@ def _fillLocationTable(self):
table = self.LOCATIONTABLE
fields = ('id','host_name', 'config')
entries=[]
entries.append((1,"tsvaccess1",0)) #KR
entries.append((2,"tsvaccess1",1)) #KR Group MO
entries.append((3,"tsvaccess1",2)) #KR Group DO
entries.append((4,"tsvaccess2",6)) #Sauna
entries.append((1,"tsvaccess1",0)) #KR with ampel
entries.append((2,"tsvaccess1",1)) #FIT Group MO
entries.append((3,"tsvaccess1",2)) #FIT Group DO
entries.append((4,"tsvaccess2",6)) #Sauna with 7-LED
entries.append((5,"tsvaccess3",3)) #Nord
entries.append((6,"tsvaccess4",4)) #Spiegelsaal
entries.append((7,"tsvaccess5",5)) #Dojo
entries.append((8,"tsvaccess6",7)) #Pending
entries.append((6,"tsvaccess4",7)) #spare
entries.append((7,"tsvaccess5",5)) #Dojo with ampel
entries.append((8,"tsvaccess6",4)) #spiegel with ampel
#entries.append((9,"msi",0))
#entries.append((10,"msi",7))
self.db.insertMany(table, fields, entries)
Expand Down

0 comments on commit dee4280

Please sign in to comment.