-
Notifications
You must be signed in to change notification settings - Fork 0
As a user, I can see my keywords #7
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
Open
rosle
wants to merge
8
commits into
feature/parse-csv
Choose a base branch
from
feature/create-keyword
base: feature/parse-csv
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
508084d
Create keyword from the parse csv
rosle 0b46dee
Update the upload controller test
rosle 59b14fe
Associate the keywords with user
rosle a91b0b5
Display keyword list
rosle f4cf521
List the keywords that belongs to the user
rosle b7fc208
Update docs and reformat the error message
rosle a44d3c4
Change put assoc to build assoc
rosle 2832b0c
Add association validation and test
rosle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| defmodule GoogleCrawlerWeb.DashboardController do | ||
| use GoogleCrawlerWeb, :controller | ||
|
|
||
| alias GoogleCrawler.Search | ||
| alias GoogleCrawler.Search.KeywordFile | ||
|
|
||
| def index(conn, _params) do | ||
| keywords = Search.list_user_keywords(conn.assigns.current_user) | ||
| changeset = KeywordFile.changeset(%KeywordFile{}) | ||
|
|
||
| render(conn, "index.html", changeset: changeset) | ||
| render(conn, "index.html", keywords: keywords, changeset: changeset) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,16 @@ | ||
| <%= render GoogleCrawlerWeb.KeywordView, "_form.html", assigns %> | ||
| <section> | ||
| <%= render GoogleCrawlerWeb.KeywordView, "_form.html", assigns %> | ||
| </section> | ||
| <hr> | ||
| <section> | ||
| <h3><%= gettext("Keywords") %></h3> | ||
| <p><%= gettext("You don't have any keywords.") %></p> | ||
| <%= if length(@keywords) == 0 do %> | ||
| <p><%= gettext("You don't have any keywords.") %></p> | ||
| <% else %> | ||
| <ul> | ||
| <%= for keyword <- @keywords do %> | ||
| <li><%= keyword.keyword %></li> | ||
| <% end %> | ||
| </ul> | ||
| <% end %> | ||
| </section> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,9 @@ | ||
| <section> | ||
| <h3><%= gettext("Upload your keyword file (.csv)") %></h3> | ||
| <p><%= gettext("📝 Please put one keyword per line") %></p> | ||
| <%= form_for @changeset, Routes.upload_path(@conn, :create), [multipart: true], fn f -> %> | ||
| <%= label f, :file %> | ||
| <%= file_input f, :file, required: true %> | ||
| <%= error_tag f, :file %> | ||
| <h3><%= gettext("Upload your keyword file (.csv)") %></h3> | ||
| <p><%= gettext("📝 Please put one keyword per line") %></p> | ||
| <%= form_for @changeset, Routes.upload_path(@conn, :create), [multipart: true], fn f -> %> | ||
| <%= label f, :file %> | ||
| <%= file_input f, :file, required: true, accept: "text/csv" %> | ||
| <%= error_tag f, :file %> | ||
|
|
||
| <%= submit gettext("Upload") %> | ||
| <% end %> | ||
| </section> | ||
| <%= submit gettext("Upload") %> | ||
| <% end %> |
11 changes: 11 additions & 0 deletions
11
priv/repo/migrations/20200330130512_add_user_id_to_keywords.exs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| defmodule GoogleCrawler.Repo.Migrations.AddUserIdToKeywords do | ||
| use Ecto.Migration | ||
|
|
||
| def change do | ||
| alter table(:keywords) do | ||
| add :user_id, references(:users, on_delete: :delete_all), null: false | ||
| end | ||
|
|
||
| create index(:keywords, [:user_id]) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| defmodule Googlecrawler.Search.KeywordTest do | ||
| use GoogleCrawler.DataCase | ||
|
|
||
| alias GoogleCrawler.Search.Keyword | ||
| alias GoogleCrawler.UserFactory | ||
| alias GoogleCrawler.KeywordFactory | ||
|
|
||
| describe "changeset" do | ||
| test "keyword is required" do | ||
| user = UserFactory.create() | ||
| attrs = KeywordFactory.build_attrs(%{keyword: "", user: user}) | ||
| changeset = Keyword.changeset(%Keyword{}, attrs) | ||
|
|
||
| refute changeset.valid? | ||
| assert %{keyword: ["can't be blank"]} = errors_on(changeset) | ||
| end | ||
|
|
||
| test "user is required" do | ||
| attrs = KeywordFactory.build_attrs() | ||
| changeset = Keyword.changeset(%Keyword{}, attrs) | ||
|
|
||
| refute changeset.valid? | ||
| assert %{user_id: ["can't be blank"]} = errors_on(changeset) | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm displaying some error message when some of the keywords cannot be created but I'm not sure how to test it 🤔💭