Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add org chart yaml #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def helper_parse_values(self, key, value, table):
template.globals['Table'] = Table()

#read yaml file
with open("ga4.yaml", "r") as val:
with open("org_chart.yaml", "r") as val:
values = yaml.safe_load(val)
output = template.render(tables=values)
#write python file
Expand Down
119 changes: 19 additions & 100 deletions fake.py
Original file line number Diff line number Diff line change
@@ -1,118 +1,37 @@
@dataclasses.dataclass
class Comments(DataUtil):
url: str = field(default_factory=itertools.count(start=1).__next__)
source_system: str = field(init=False)
created_at: datetime = field(init=False)
comment_text: str = field(init=False)
comment_reference: str = field(init=False)
user_name: str = field(init=False)

def __post_init__(self):
self.source_system = self.random_item(population=['GMB', 'YT'])
self.created_at = self.created_at(datetime.datetime(2022, 1, 1))
self.comment_text = ##FILL ME IN
self.comment_reference = ##FILL ME IN
self.user_name = ##FILL ME IN

def __str__(self):
return f'{self.url},{self.source_system},{self.created_at},{self.comment_text},{self.comment_reference},{self.user_name}'
from utils import DataUtil
import dataclasses
from dataclasses import field
import itertools
import datetime
import faker
fake = faker.Faker()

@dataclasses.dataclass
class Products(DataUtil):
id: int = field(default_factory=itertools.count(start=1).__next__)
offer_id: int = field(init=False)
title: str = field(init=False)
description: str = field(init=False)
link: str = field(init=False)
image_link: str = field(init=False)
channel: str = field(init=False)
availability: str = field(init=False)
price: float = field(init=False)
gtin: str = field(init=False)
google_product_category_path: str = field(init=False)

def __post_init__(self):
self.offer_id = ##FILL ME IN
self.title = ##FILL ME IN
self.description = ##FILL ME IN
self.link = ##FILL ME IN
self.image_link = ##FILL ME IN
self.channel = ##FILL ME IN
self.availability = ##FILL ME IN
self.price == self.random_int(0, 100)
self.gtin = ##FILL ME IN
self.google_product_category_path = ##FILL ME IN

def __str__(self):
return f'{self.id},{self.offer_id},{self.title},{self.description},{self.link},{self.image_link},{self.channel},{self.availability},{self.price},{self.gtin},{self.google_product_category_path}'

@dataclasses.dataclass
class Inventory(DataUtil):
product_id: str = field(init=False)
store_code: str = field(init=False)
availability: str = field(init=False)
quantity: int = field(init=False)

products:InitVar[Any] = None
def __post_init__(self, products=None):
self.product_id == products.id
self.store_code = ##FILL ME IN
self.availability = ##FILL ME IN
self.quantity == self.random_int(0, 5)

def __str__(self):
return f'{self.product_id},{self.store_code},{self.availability},{self.quantity}'

@dataclasses.dataclass
class Stores(DataUtil):
store_code: str = field(init=False)
location: coordinate = field(init=False)
store_name: str = field(init=False)

def __post_init__(self):
self.store_code = ##FILL ME IN
self.location = ##FILL ME IN
self.store_name = self.random_item(population=['store1', 'store2'])

def __str__(self):
return f'{self.store_code},{self.location},{self.store_name}'

@dataclasses.dataclass
class Customers(DataUtil):
class Employees(DataUtil):
id: int = field(default_factory=itertools.count(start=1).__next__)
gender: str = field(init=False)
first_name: str = field(init=False)
last_name: str = field(init=False)
loyalty_id: str = field(init=False)
email: str = field(init=False)
level: int = field(init=False)
role: str = field(init=False)

def __post_init__(self):
self.gender = self.random_item(population=['male', 'female', 'nonbinary'])
self.gender = self.random_item(population=['male', 'female', 'nonbinary'], distribution=[0.4, 0.5, 0.1])
if self.gender == 'male':
self.first_name = fake.first_name_male()
if self.gender == 'female':
self.first_name = fake.first_name_female()
if self.gender == 'nonbinary':
self.first_name = fake.first_name_nonbinary()
self.last_name = fake.last_name_nonbinary()
self.loyalty_id = ##FILL ME IN

def __str__(self):
return f'{self.id},{self.gender},{self.first_name},{self.last_name},{self.loyalty_id}'

@dataclasses.dataclass
class Transactions(DataUtil):
id: int = field(default_factory=itertools.count(start=1).__next__)
customer_id: int = field(init=False)
product_id: int = field(init=False)
cost: float = field(init=False)

customers:InitVar[Any] = None
products:InitVar[Any] = None
def __post_init__(self, customers=None, products=None):
self.customer_id == customers.id
self.product_id == products.id
self.cost == self.random_int(0, 100)
self.email = f'{self.first_name.lower()}{self.last_name.lower()}@testco.com'
self.level == self.random_int(1, 5)
self.role = self.random_item(population=['account executive', 'sales engineer', 'customer success analyst', 'engineer', 'recruiter'], distribution=[0.6, 0.1, 0.1, 0.1, 0.1])

def __str__(self):
return f'{self.id},{self.customer_id},{self.product_id},{self.cost}'
return f'{self.id},{self.gender},{self.first_name},{self.last_name},{self.email},{self.level},{self.role}'

if __name__ == "__main__":
for i in range(100):
print(Employees())
33 changes: 33 additions & 0 deletions org_chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Employees:
id: { type: int, primary_key: True }
gender:
{
type: str,
values: ["male", "female", "nonbinary"],
distribution: [.4, .5, .1],
}
first_name: { type: str, depends_on: ["gender"] }
last_name: { type: str }
# phone_number: { type: str }
email: { type: str, domain: "testco.com" }
level: { type: int, dist: { min: 1, max: 5 } }
# org:
# {
# type: str,
# values:
# ["sales", "marketing", "engineering", "product", "customer sucess"],
# }
# role: { type: str, depends_on: ["org"] }
role:
{
type: str,
values:
[
"account executive",
"sales engineer",
"customer success analyst",
"engineer",
"recruiter",
],
distribution: [.6, .1, .1, .1, .1],
}