11# The starting point for this code is from GPT4: https://chat.openai.com/share/df0f70f0-b2a0-44b7-8c48-e252ad95ca24
2- # At this point it has no tests, etc.
3- from pymongo import MongoClient
2+ # TODO: Uncomment out and factor out the Database logic below
3+ # from pymongo import MongoClient
44
55class Rule :
66 def __init__ (self , word , divisor ):
@@ -19,22 +19,24 @@ def get_rules_from_db(collection):
1919 return rules
2020
2121def fizz_buzz (i , rules = None ):
22- # Uses default rules from MongoDB if no rules are specified
23- if rules is None :
24- rules = default_rules_from_db
22+ # TODO: Use default rules from MongoDB if no rules are specified
23+ # if rules is None:
24+ # rules = default_rules_from_db
2525 output = []
2626 for rule in rules :
2727 if i % rule .divisor == 0 or str (rule .divisor ) in str (i ):
2828 output .append (rule .word )
2929 return '' .join (output ) if output else str (i )
3030
31- # MongoDB connection setup
32- client = MongoClient ('mongodb://localhost:27017/' ) # Connect to your MongoDB server
33- db = client ['fizzbuzz_db' ] # Specify the database
34- collection = db ['rules' ] # Specify the collection
31+ # TODO: DB work:
3532
36- # Fetch default rules from MongoDB
37- default_rules_from_db = get_rules_from_db (collection )
33+ # # MongoDB connection setup
34+ # client = MongoClient('mongodb://localhost:27017/') # Connect to your MongoDB server
35+ # db = client['fizzbuzz_db'] # Specify the database
36+ # collection = db['rules'] # Specify the collection
3837
39- # Example usage of the fizz_buzz function with MongoDB
40- print ([fizz_buzz (i ) for i in range (1 , 16 )]) # Uses default rules
38+ # # Fetch default rules from MongoDB
39+ # default_rules_from_db = get_rules_from_db(collection)
40+
41+ # # Example usage of the fizz_buzz function with MongoDB
42+ # print([fizz_buzz(i) for i in range(1, 16)]) # Uses default rules
0 commit comments