Skip to content
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #207 from mememori/view-improvement
Browse files Browse the repository at this point in the history
View improvement
  • Loading branch information
mememori committed May 10, 2017
2 parents d09232e + 7292553 commit 52b26c9
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 26 deletions.
11 changes: 2 additions & 9 deletions .ebert.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# This configuration was used Ebert to review the HackerExperience/Helix repository
# on 4c6e317551396af8a822b36df2556781e259fbc5.
# You can make this the default configuration for future reviews by moving this
# file to your repository as `.ebert.yml` and pushing it to GitHub, and tweak
# it as you wish - To know more on how to change this file to better review your
# repository you can go to https://ebertapp.io/docs/config and see the configuration
# details.
---
styleguide: plataformatec/linters
engines:
credo:
Expand All @@ -16,8 +8,9 @@ engines:
enabled: true
remark-lint:
enabled: true
pull_requests:
comments: false
exclude_paths:
- config
- priv/repo
- test

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/cover
/deps
/doc
/docs/all.json
erl_crash.dump
*.ez

Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ elixir:
otp_release:
- 19.3
script:
- "MIX_ENV=test mix do deps.get, compile, ecto.setup, coveralls.travis"
- "MIX_ENV=test mix do deps.get, compile, ecto.setup, coveralls.travis, inch.report"
services:
- postgresql
addons:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center"><img src="help/logo.png" /></p>


# Helix [![Build Status](https://ci.hackerexperience.com/buildStatus/icon?job=HackerExperience/Helix/master)](https://ci.hackerexperience.com/job/HackerExperience/job/Helix/job/master) [![Ebert](https://ebertapp.io/github/HackerExperience/Helix.svg)](https://ebertapp.io/github/HackerExperience/Helix) ![](https://tokei.rs/b1/github/hackerexperience/helix) [![Coverage Status](https://coveralls.io/repos/github/HackerExperience/Helix/badge.svg?branch=master)](https://coveralls.io/github/HackerExperience/Helix?branch=master)
# Helix [![Build Status](https://ci.hackerexperience.com/buildStatus/icon?job=HackerExperience/Helix/master)](https://ci.hackerexperience.com/job/HackerExperience/job/Helix/job/master) [![Coverage Status](https://coveralls.io/repos/github/HackerExperience/Helix/badge.svg?branch=master)](https://coveralls.io/github/HackerExperience/Helix?branch=master) [![Inline docs](http://inch-ci.org/github/HackerExperience/Helix.svg)](http://inch-ci.org/github/HackerExperience/Helix) [![Ebert](https://ebertapp.io/github/HackerExperience/Helix.svg)](https://ebertapp.io/github/HackerExperience/Helix) ![](https://tokei.rs/b1/github/hackerexperience/helix)
---

Helix is the backend powering the game **Hacker Experience 2**.
Expand Down
17 changes: 2 additions & 15 deletions lib/server/websocket/channel/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ defmodule Helix.Server.Websocket.Channel.Server do
alias Helix.Software.Service.API.File, as: FileAPI
alias Helix.Software.Service.Flow.FileDownload
alias Helix.Software.Service.Flow.LogDeleter
alias Helix.Software.Public.View.File, as: FileView
alias Helix.Server.Service.API.Server, as: ServerAPI
alias Helix.Server.Service.Henforcer.Server, as: Henforcer

Expand Down Expand Up @@ -178,22 +179,8 @@ defmodule Helix.Server.Websocket.Channel.Server do
# %{"foo" => [1, 2]}
Map.merge(acc, el, fn _k, v1, v2 -> v1 ++ v2 end)
end)
# HACK: FIXME: This belongs to a viewable protocol. We're doing it as it
# is now so it works before we do the real work (?)
|> Enum.map(fn {path, files} ->
files = for file <- files do
Map.take(
file,
[
:file_id,
:name,
:path,
:full_path,
:file_size,
:software_type,
:inserted_at,
:updated_at])
end
files = Enum.map(files, &FileView.render/1)

{path, files}
end)
Expand Down
28 changes: 28 additions & 0 deletions lib/software/public/view/file.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
defmodule Helix.Software.Public.View.File do

alias Helix.Software.Model.File

@spec render(File.t) ::
%{
file_id: HELL.PK.t,
path: String.t,
size: non_neg_integer,
software_type: String.t,
inserted_at: DateTime.t,
updated_at: DateTime.t,
meta: map,
modules: map
}
def render(file = %File{}) do
%{
file_id: file.file_id,
path: file.full_path,
size: file.file_size,
software_type: file.software_type,
inserted_at: file.inserted_at,
updated_at: file.updated_at,
meta: %{},
modules: %{}
}
end
end
2 changes: 2 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ defmodule Helix.Mixfile do
{:earmark, "~> 1.1", only: :dev},
{:ex_doc, "~> 0.15", only: :dev},

{:inch_ex, "~> 0.5.6", only: [:dev, :test]},

{:credo, "~> 0.7", only: [:dev, :test]},
{:excoveralls, "~> 0.6.3", only: [:dev, :test]}
]
Expand Down

0 comments on commit 52b26c9

Please sign in to comment.