Compare commits

...

3 commits

Author SHA1 Message Date
Enrique Barcelli e44414fa65
Update SECURITY.md 2025-03-10 16:55:48 +08:00
Enrique Barcelli 327f0d9b98
Update README.md 2025-03-10 16:51:13 +08:00
Enrique Barcelli 51d6738304
Add delete functionality 2025-03-10 16:43:04 +08:00
4 changed files with 37 additions and 0 deletions

View file

@ -13,4 +13,5 @@ These Python scripts allow to extract records from the DineConnect API and post
* Copy the file `config-sample.py` to `config.py`.
* Edit `config.py` with your credentials and defaults.
* To extract the tickets records from the DineConnect API and post them to the Mongo database, run `python3 extract_tickets.py` and follow the instructions of the script.
* To delete tickets from the Mongo database, run `python3 delte_tickets.py` and follow de instructions of the script.

View file

@ -4,6 +4,7 @@
| Version | Supported |
| ------- | ------------------ |
| 0.2.x | :heavy_check_mark: |
| 0.1.x | :heavy_check_mark: |
## Reporting

16
delete.py Normal file
View file

@ -0,0 +1,16 @@
from pymongo import MongoClient
from config import *
import sys
import json
def delete(query_filter):
client = MongoClient(CONNECTION_STRING)
database = client[DATABASE]
collection = database[COLLECTION]
result = collection.delete_many(json.loads(query_filter))
print(result.raw_result)
if __name__ == '__main__':
delete(sys.argv[1])

19
delete_tickets.py Normal file
View file

@ -0,0 +1,19 @@
import requests
import json
from config import *
from delete import *
import sys
import base64
def delete_tickets():
from_date = str(input('From date [YYYY-MM-DD]: ') or "")
to_date = str(input('To date YYYY-MM-DD]: ') or "")
query_filter = json.dumps({
"businessDate": {'$gte': from_date+"T00:00:00", '$lte': to_date+"T00:00:00"}
})
print(query_filter)
delete(query_filter)
if __name__ == '__main__':
delete_tickets()