Compare commits
3 commits
78194437a9
...
e44414fa65
Author | SHA1 | Date | |
---|---|---|---|
|
e44414fa65 | ||
|
327f0d9b98 | ||
|
51d6738304 |
|
@ -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.
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 0.2.x | :heavy_check_mark: |
|
||||
| 0.1.x | :heavy_check_mark: |
|
||||
|
||||
## Reporting
|
||||
|
|
16
delete.py
Normal file
16
delete.py
Normal 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
19
delete_tickets.py
Normal 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()
|
||||
|
Loading…
Reference in a new issue