Commit 6105cc7b authored by ReemyHasan's avatar ReemyHasan

Add rethink scheduler

parent e47acd41
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (SchedulingRethink)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/SchedulingRethink.iml" filepath="$PROJECT_DIR$/.idea/SchedulingRethink.iml" />
</modules>
</component>
</project>
\ No newline at end of file
import rethinkdb as r
import datetime
import pytz
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
rdb = r.RethinkDB()
conn = rdb.connect("172.29.3.220",28015).repl()
s = rdb.db("Traps").table("Raw-Traps").run()
time_threshold = 60*1000
tz = pytz.timezone('Etc/GMT-3')
current_datetime = datetime.datetime.now(tz)
timestamp = current_datetime.timestamp()*1000
e = rdb.db("Traps").table('Raw-Traps').filter((timestamp - rdb.row['date']) > time_threshold).delete().run()
#print(e)
with open(os.path.join(dir_path, 'output.txt'), 'a') as f:
f.write(str(current_datetime))
f.write(": ")
f.write(str(e))
f.write('\n')
conn.close()
\ No newline at end of file
2023-07-18 14:03:34.161638+03:00: {'deleted': 27, 'errors': 0, 'inserted': 0, 'replaced': 0, 'skipped': 0, 'unchanged': 0}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment