Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
acb0562
First commit going to branch to make changes.
Sep 22, 2021
5d684de
Added the company and the association with user. But have not added a…
Nov 26, 2021
a3aac3d
Merge pull request #1 from ceejaay/new-model
Ceejaay Nov 27, 2021
002d82a
removed some migrations
Nov 27, 2021
e5c12aa
Have company model
Nov 27, 2021
90efde7
Merge pull request #2 from ceejaay/company-model
Ceejaay Nov 27, 2021
e6fdf5e
Fixed companies. Related company to transaction. seeded db
Dec 5, 2021
b01de93
Merge pull request #3 from ceejaay/fix-company
Ceejaay Dec 5, 2021
d7ad38c
Some change to tests
Dec 5, 2021
f8ba1d8
Closer to adding a company
Dec 5, 2021
d9168d6
Working on making companies work in the graphiql
Dec 5, 2021
8da541b
Can see all the models in tdhe graphql thingy
Dec 5, 2021
d5264dd
Working on making companies work in the graphiql
Dec 5, 2021
8c58a8b
Merge pull request #4 from ceejaay/basic-tests
Ceejaay Dec 5, 2021
7595bd3
Added the seed file
Dec 6, 2021
9ab0e3c
Merge pull request #5 from ceejaay/connect-users-transactions-companies
Ceejaay Dec 6, 2021
2d4c1ba
Added req. file for seeding
Dec 6, 2021
8d4de38
Added some README documentation
Dec 6, 2021
292a1df
Formatting
Dec 6, 2021
d964f3f
Update the readme.
Dec 6, 2021
5f38dce
Updated the readme
Dec 6, 2021
9b2577e
The final commit and merge.
Dec 6, 2021
06519b4
Merge pull request #6 from ceejaay/submit
Ceejaay Dec 6, 2021
74bea55
Have the basics of a seed file. Can seed Company with faker name
Jan 5, 2022
0c26499
Can add all the elements. Just need to combine them in a way so they …
Jan 5, 2022
7ebad80
Can add companies and associate users.
Jan 7, 2022
6dc268a
Laying ground work for transactions
Jan 7, 2022
e2ebdd0
Working seeding script. Adds everything. But does not calculate compa…
Jan 8, 2022
44d2e57
Restored the default variables. Added the POSTGRES_USER variable to m…
Jan 8, 2022
a7d302f
updated readme and seed file
Jan 10, 2022
7a1d1ce
Merge pull request #7 from ceejaay/new-seeding
Ceejaay Jan 10, 2022
3848687
Fixed formatting on README
Jan 10, 2022
fd6bf84
Fixed more formatting on README
Jan 10, 2022
42203a9
Fixed further problems on the README
Jan 10, 2022
c85b914
Fixed some grammar and tagged the Devs for review
Ceejaay Jan 10, 2022
ff4c9e8
Added a some new files for toy db
May 29, 2022
e584460
Merge branch 'new-model'
May 29, 2022
ed7f8c9
Updated the tests to handle the new company module
Aug 13, 2022
144556d
Merge pull request #8 from ceejaay/credit-total
Ceejaay Aug 13, 2022
9845bb9
Wrote a test to check for new credit line after new transaction
Aug 14, 2022
2886d7d
Merge pull request #9 from ceejaay/company-credit-tracking
Ceejaay Aug 14, 2022
0ac68b7
Fixed the broken company_list tests. needed to add the OTHER company …
Aug 17, 2022
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
101 changes: 101 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,106 @@
# Divvy Homework Assignment

### Chad Jemmett's Divvy Homework Project -- Updated Jan 9, 2022

To Divvy Devs,
Thank you for your feedback on my homework project. Kris Rickard sent me the feedback you gave on my work. I've copied
the pros and cons list here for your convenience.
To reiterate, this is the kind of work you can expect from me as a memeber of the Divvy team. I welcome feedback. I
research my mistakes and upate my work in a timely manner. I enjoy collaboration and being part of a team. I look
forward to doing an in-person code review with the Divvy Team.

> Pros:
> Company addition is clean and tests look good
> Seeds file is really robust… but it’s in python
> Cons:
> Definitely signs of a mid-level. Replaced default database creds instead of using system env, wrote a python seeds file instead of using elixir because it was more familiar.
> Questions:
> What is the risk/reward of adding python to an elixir project?
> How will you plan to learn elixir?

The following are my corrections listed under CONS.

I've written a [seed file in Elixir here.](https://github.com/ceejaay/web-homework/blob/master/elixir/priv/repo/seeds.exs)
This is written entirely in Elixir. I enumerate over a range of integers and lists of items retreived from the database
to insert Companies, Users, Merchants and Transactions into the database. I used the Faker module to write dummy data.

I solved the problem of altering the default database credentials. I did research on Elixir's `System` module. I
set my PostgreSQL username in my `.zshrc` file. It solved the problem and I restored the default variables in the
[config/dev.exs](https://github.com/ceejaay/web-homework/blob/master/elixir/config/dev.exs) and the [prod.secret.exs](https://github.com/ceejaay/web-homework/blob/master/elixir/config/prod.secret.exs) files.


### Answers to Questions

#### What is the risk/reward of adding Python to an Elixir project?

I would say the risks outweigh the rewards when adding Python to an Elixir application. I currently work on a Python and Django project with several apps. It’s beneficial to my team and I that we only have one language to manage when doing the majority of our work. Only a very serious problem would cause me to consider adding another language. And the solution to that problem would be something that *only* a new language could solve. I would first attempt to solve the problem using Python. If that didn’t work, I’d consider something else.


I think the most frustrating risk of adding Python to an Elixir app would be a workflow problem. I personally dislike stopping my work in Python and moving to another language in my process. It’s more efficient to stay working in one language and its related framework.



As far as rewards, any script or app written in Python would be easy to get up and running. For a short-term solution to a problem, Python is a good choice. Right now, [Python is the second most popular language on Github.](https://madnight.github.io/githut/#/pull_requests/2021/4) Many experienced developers would easily find the right Python library to solve the problem. You may not even need extra libraries. Python has many options right out of the box. And the popularity of Python means any future developer wouldn’t need much to write new features for the app.


Overall, It wouldn’t be my first choice to add Python to an Elixir app. But if I had to, Python wouldn’t be a bad choice.

#### How will you plan to learn Elixir?

This bit of pseudo-code illustrates my learning process.
```
while elixir_expert == False:
study_elixir_topic()
apply_knowledge_to_simple_project()
ask_for_feedback_from_experienced_devs()

```

I’ve already started the feedback process. I’ve taken a Udemy course on Elixir. It’s a bit dated but I learned the
basics of the language. The tutorial builds two small programs. [The first is a basic program to shuffle and deal a
deck of cards.](https://github.com/ceejaay/elixir_card_shuffler) The second is far more interesting and fun. [It’s a script that generates identicon images.](https://github.com/ceejaay/elixir_project) Identicons are those random geometric images you see as profile pictures on some websites.

As for questions and feedback. I’ve asked some questions in the Discord Elixir channel. The people there are very helpful. I look forward to working on the Divvy team and getting feedback from experienced developers.

Part of my strategy is looking for interesting problem when building a simple project.I really enjoyed the problems presented in writing the `seed.exs` file for the homework. I understood the basics of creating and inserting an item into the database. But I needed a lot of research on how to handle the relationships and inserting a large amount of data.

This process has resulted in success for me. Doing hobby projects in Ruby laid the foundation for the work I would do in my bootcamp, and that success brought me to my current job. You’ll see that this process will make me an excellent addition to the Divvy team.


# Below is my original homework project you gave feedback on.


The first is in this repository. It demonstrates my abilities in Elixir, Ecto and Phoenix.
The second is here: [It is a demonstration of my ability to write an api in
Python.](https://github.com/ceejaay/transaction_tracker)

Please visit my other repository to review the project. It is an example of the kind of work I do at my current job.

### My work in this Elixir project.
I made two accomplishments on this project.

1. I wrote a python script to seed the database.
2. I created the components of a new `Company` model.

The python script to seed the database is here: [Seed File.](https://github.com/ceejaay/web-homework/blob/master/seed.py)
At first I researched how to seed the database with the existing `seed` file included in the Homework app. I found the
learning curve to be steep, so I accomplished the task with the tools I am most familiar with. I used python and a
couple of libraries to seed the Postgres database.
You can read instructions to run the seed in the `seed.py` file.

For the `Company` model. I researched the Ecto documentation on their website. First I generated a context for the
Company model. I then manually created the relation among the `Company`, `User`, and `Transaction`.
I created the shchema and resolvers for the model.

Thank you for your consideration. I look forward to your feedback on my work in our future interview.
Please contact me at your earliest convenience so we can talk about my work.

- Chad Jemmett
chad.jemmett@gmail.com
208-305-0359


*************************************************************************************************
This repository provides a starting point for a basic React + GraphQL application.
All of the configuration boilerplate is complete so you can start by writing the code that you want us to see.

Expand Down
1 change: 1 addition & 0 deletions elixir/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"POSTGRES_USER" = "cjem"
3 changes: 2 additions & 1 deletion elixir/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# is restricted to this project.

# General application configuration
use Mix.Config
# use Mix.Config
import Config

config :homework,
ecto_repos: [Homework.Repo]
Expand Down
4 changes: 3 additions & 1 deletion elixir/config/dev.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use Mix.Config
# use Mix.Config

import Config

# Configure your database
config :homework, Homework.Repo,
Expand Down
2 changes: 1 addition & 1 deletion elixir/config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Mix.Config
# Run `mix help test` for more information.
config :homework, Homework.Repo,
username: System.get_env("POSTGRES_USER") || "postgres",
password: System.get_env("POSTGRES_PASSWORD") || "postgres",
password: System.get_env("POSTGRES_PASSWORD") || "",
hostname: System.get_env("POSTGRES_HOST") || "localhost",
database: System.get_env("POSTGRES_DATABASE") || "homework_dev",
pool: Ecto.Adapters.SQL.Sandbox
Expand Down
104 changes: 104 additions & 0 deletions elixir/lib/homework/account.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
defmodule Homework.Account do
@moduledoc """
The Account context.
"""

import Ecto.Query, warn: false
alias Homework.Repo

alias Homework.Account.Card

@doc """
Returns the list of cards.

## Examples

iex> list_cards()
[%Card{}, ...]

"""
def list_cards do
Repo.all(Card)
end

@doc """
Gets a single card.

Raises `Ecto.NoResultsError` if the Card does not exist.

## Examples

iex> get_card!(123)
%Card{}

iex> get_card!(456)
** (Ecto.NoResultsError)

"""
def get_card!(id), do: Repo.get!(Card, id)

@doc """
Creates a card.

## Examples

iex> create_card(%{field: value})
{:ok, %Card{}}

iex> create_card(%{field: bad_value})
{:error, %Ecto.Changeset{}}

"""
def create_card(attrs \\ %{}) do
%Card{}
|> Card.changeset(attrs)
|> Repo.insert()
end

@doc """
Updates a card.

## Examples

iex> update_card(card, %{field: new_value})
{:ok, %Card{}}

iex> update_card(card, %{field: bad_value})
{:error, %Ecto.Changeset{}}

"""
def update_card(%Card{} = card, attrs) do
card
|> Card.changeset(attrs)
|> Repo.update()
end

@doc """
Deletes a card.

## Examples

iex> delete_card(card)
{:ok, %Card{}}

iex> delete_card(card)
{:error, %Ecto.Changeset{}}

"""
def delete_card(%Card{} = card) do
Repo.delete(card)
end

@doc """
Returns an `%Ecto.Changeset{}` for tracking card changes.

## Examples

iex> change_card(card)
%Ecto.Changeset{data: %Card{}}

"""
def change_card(%Card{} = card, attrs \\ %{}) do
Card.changeset(card, attrs)
end
end
17 changes: 17 additions & 0 deletions elixir/lib/homework/account/card.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defmodule Homework.Account.Card do
use Ecto.Schema
import Ecto.Changeset

schema "cards" do
field :description, :string

timestamps()
end

@doc false
def changeset(card, attrs) do
card
|> cast(attrs, [:description])
|> validate_required([:description])
end
end
104 changes: 104 additions & 0 deletions elixir/lib/homework/companies.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
defmodule Homework.Companies do
@moduledoc """
The Companies context.
"""

import Ecto.Query, warn: false
alias Homework.Repo

alias Homework.Companies.Company

@doc """
Returns the list of company.

## Examples

iex> list_company()
[%Company{}, ...]

"""
def list_company(_args) do
Repo.all(Company)
end

@doc """
Gets a single company.

Raises `Ecto.NoResultsError` if the Company does not exist.

## Examples

iex> get_company!(123)
%Company{}

iex> get_company!(456)
** (Ecto.NoResultsError)

"""
def get_company!(id), do: Repo.get!(Company, id)

@doc """
Creates a company.

## Examples

iex> create_company(%{field: value})
{:ok, %Company{}}

iex> create_company(%{field: bad_value})
{:error, %Ecto.Changeset{}}

"""
def create_company(attrs \\ %{}) do
%Company{}
|> Company.changeset(attrs)
|> Repo.insert()
end

@doc """
Updates a company.

## Examples

iex> update_company(company, %{field: new_value})
{:ok, %Company{}}

iex> update_company(company, %{field: bad_value})
{:error, %Ecto.Changeset{}}

"""
def update_company(%Company{} = company, attrs) do
company
|> Company.changeset(attrs)
|> Repo.update()
end

@doc """
Deletes a company.

## Examples

iex> delete_company(company)
{:ok, %Company{}}

iex> delete_company(company)
{:error, %Ecto.Changeset{}}

"""
def delete_company(%Company{} = company) do
Repo.delete(company)
end

@doc """
Returns an `%Ecto.Changeset{}` for tracking company changes.

## Examples

iex> change_company(company)
%Ecto.Changeset{data: %Company{}}

"""
def change_company(%Company{} = company, attrs \\ %{}) do
Company.changeset(company, attrs)
end
end
22 changes: 22 additions & 0 deletions elixir/lib/homework/companies/company.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
defmodule Homework.Companies.Company do
use Ecto.Schema
import Ecto.Changeset
alias Homework.Companies.Company

@primary_key {:id, :binary_id, autogenerate: true}
schema "company" do
field :available_credit, :integer
field :credit_line, :integer
field :name, :string
has_many :users, Company

timestamps()
end

@doc false
def changeset(company, attrs) do
company
|> cast(attrs, [:name, :credit_line, :available_credit])
|> validate_required([:name, :credit_line, :available_credit])
end
end
Loading