Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
serra committed Sep 25, 2024
1 parent f0b3c94 commit a2911ba
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,33 @@ The application is published as a Docker container to <https://ghcr.io/serraict/

For an example of the required environment variables, see [.env.example](.env.example).

When setup, then:

```bash
(venv) ➜ vine-floriday-adapter git:(main) floridayvine init-db
Initializing database on mongodb://root:'*****'@localhost:27017...
Created collection: organizations
Created collection: trade_items
(venv) ➜ vine-floriday-adapter git:(main) floridayvine print-sync-status
Max sequence number for organizations: 0
Max sequence number for trade_items: 0
(venv) ➜ vine-floriday-adapter git:(main) ✗ floridayvine sync-organizations --limit-result 3
Syncing organizations from 0 to 1164016 ...
Seq nr 864747: Persisting Douwe Hoving | Potplanten ...
Seq nr 864921: Persisting Planten Centrum Twente ...
Seq nr 867216: Persisting VOF van Kester-Duijvesteijn ...
Done syncing organizations
^C
(venv) ➜ vine-floriday-adapter git:(main) ✗ floridayvine print-sync-status
Max sequence number for organizations: 867216
Max sequence number for trade_items: 0
(venv) ➜ vine-floriday-adapter git:(main) ✗ floridayvine sync-organizations --start-seq-number 867216 --limit-result 100
[...]
Seq nr 933052: Persisting ...
Seq nr 933053: Persisting Razek Saliman ...
Done syncing organizations
```

### As a Python script

Follow the steps in Development.
Expand Down
2 changes: 1 addition & 1 deletion src/floridayvine/floriday/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ def sync_trade_items(start_seq_number=0, limit_result=5):
)
persist("trade_items", item.trade_item_id, item.to_dict())
my_sequence = trade_items_sync_result.maximum_sequence_number
print(f"Next sequence number: {my_sequence}")
time.sleep(0.5)

print("Done syncing trade items")
4 changes: 0 additions & 4 deletions src/floridayvine/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ def print_sync_status():


def persist(collection: str, _id: str, data: dict):
"""
Persist data to the database.
"""
print(f"Persisting data to {collection} on {mongodb_connection_string}...")
with MongoClient(mongodb_connection_string) as client:
db = client[DATABASE]
coll = db[collection]
Expand Down

0 comments on commit a2911ba

Please sign in to comment.