Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nubank
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Javier Biaggioli
nubank
Commits
32c594b3
Commit
32c594b3
authored
8 years ago
by
Eric Biagioli
Browse files
Options
Downloads
Patches
Plain Diff
documentation in markdown format
parent
f4ea4ffc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+141
-15
141 additions, 15 deletions
README.md
with
141 additions
and
15 deletions
README.md
+
141
−
15
View file @
32c594b3
#Reward System
#Reward System
##### by Eric Biagioli
This is the implementation of the problem that I have been asked to solve as
This is the implementation of the problem that I have been asked to solve as
part of the recruiting process at NUBANK.
part of the recruiting process at NUBANK.
####Outline of this document:
####Outline of this document:
1.
[Diclaimer] (#Disclaimer)
1.
[Diclaimer] (#disclaimer)
2.
[Theoretical Considerations] (#Theoretical Considerations)
2.
[Theoretical Considerations] (#theoretical-considerations)
3.
[Implementation Overview] (#Implementation Overview)
3.
[Implementation Overview] (#implementation-overview)
4.
[Install and build] (#Install and build)
4.
[Build and run] (#build-and-run)
5.
[A demo] (#A demo)
5.
[Demos] (#demos)
6.
[TO-DO's] (#TO-DO's)
##Disclaimer
##Disclaimer
...
@@ -63,16 +62,21 @@ is not even considerated, given that our graph is going to be very very sparse)
...
@@ -63,16 +62,21 @@ is not even considerated, given that our graph is going to be very very sparse)
we can have a very simple structure, in which each node is characterized by
we can have a very simple structure, in which each node is characterized by
four values:
four values:
**(ID _:: Int_ , PARENT _:: Int_ , HAS-CHILDS _:: Boolean_ , SCORE _:: Rational_)**
**
(ID _:: Int_ , PARENT _:: Int_ , HAS-CHILDS _:: Boolean_ ,
SCORE _:: Rational_)
**
If we just keep a set of such nodes, adding a _new edge_ from A to B (i.e.: a
If we just keep a set of such nodes, adding a _new edge_ from A to B (i.e.: a
new invitation, sent from A to B) to the _graph_ will match one of the four
new invitation, sent from A to B) to the _graph_ will match one of the four
following cases:
following cases:
*
<tt>
the first invitation sent by A;
the first received by B
</tt>
*
<tt>
the first invitation sent by
*
<tt>
the first invitation sent by A;
*not*
the first received by B
</tt>
A;
the first received by B
</tt>
*
<tt>
*not*
the first invitation sent by A;
the first received by B
</tt>
*
<tt>
the first invitation sent by
*
<tt>
*not*
the first invitation sent by A;
*not*
the first received by B
</tt>
A;
*not*
the first received by B
</tt>
*
<tt>
*not*
the first invitation sent by
A;
the first received by B
</tt>
*
<tt>
*not*
the first invitation sent by
A;
*not*
the first received by B
</tt>
If there exist an invitation from A to anyone, the property
*HAS-CHILDS*
If there exist an invitation from A to anyone, the property
*HAS-CHILDS*
of A is True. When this property _changes_ in some node, all its predecessors's
of A is True. When this property _changes_ in some node, all its predecessors's
...
@@ -129,8 +133,130 @@ The part of the server and keep the input state is mainly located at the files
...
@@ -129,8 +133,130 @@ The part of the server and keep the input state is mainly located at the files
Server.hs and AcidInput.hs. The part of the punctuation system is located at
Server.hs and AcidInput.hs. The part of the punctuation system is located at
the file PunctuationSystemV1.hs (and PunctuationSystemV2.hs).
the file PunctuationSystemV1.hs (and PunctuationSystemV2.hs).
##Install and build
##Build and run
As I mentioned several times along this documentation, this is my very first
experience with Haskell. This includes the _packaging_ process. Instead of
creating a package using _cabal_ or _stack_, I will try to describe the process
of installation of all the development tools and how to use them to compile the
program.
**ONE IMPORTANT NOTE:**
It doesn't matter which operating system or architecture
you use, it doesn't matter which compilation method you use. At the end, at the
moment of executing the binary,
**
IN THE SAME DIRECTORY THAN THE EXECUTABLE
FILE MUST BE A DIRECTORY (CAN BE EMPTY, BUT MUST BE THERE) NAMED tmp. THE USER
WHO LAUNCHES THE EXECUTABLE MUST HAVE WRITE PERMISSIONS ON THE tmp DIRECTORY
**
I have developed on linux, on Ubuntu. I have tested the following recipe both in
Windows 10 and in Ubuntu.
####Ubuntu:
1.
Install [Haskell Platform] (https://www.haskell.org/platform/):
`sudo apt-get install haskell-platform`
2.
Update cabal database (cabal is a packages manager for Haskell):
`sudo cabal update`
3.
Install
`happstack`
(more information
[here] (http://www.happstack.com/page/view-page-slug/2/download))
`export PATH=~/.cabal/bin:$PATH`
`sudo cabal install happstack-server`
4.
Install
`acid-state`
:
`sudo cabal install acid-state`
5.
Compile the project:
If you have `make` installed on your system, you can go to the root directory
of the project (the directory containing the Makefile) and execute `make`.
This will do the job.
If you don't have `make` installed on your system, you can go inside the
the `src` directory and execute
`ghc --make Main.hs -o rewardsystem`
**Observation:** the binary named _rewardsystem_, in this case, must be
manually moved to the root directory (since it will be inside the src
directory). This is necessary because inside the root directory exists a
directory named _tmp_, and this is mandatory for the execution of the
program.
**IMPORTANT NOTE: In the same folder than this executable must be a folder
named _tmp_, and the user who launches the executable must have permissions
to write in tmp**
6.
Execute _Server_ and play... It listens on port 8000. You can either use
curl or the browser to test it. See the section in which I include a DEMO
for further details.
####Windows 10:
1.
Install [Haskell Platform] (https://www.haskell.org/platform/). Choose the
_Download Full_ option.
**NOTE**
that there is a manual step that you need
to perform. The step 3 tells you to modify the cabal configuration file. If
you forget to do this, you will not be able to install happstack (one of the
packages that we will need to install).
2.
Update cabal database (cabal is a packages manager for Haskell). Launch
**
as
administrator
**
the command prompt and type
`cabal update`
3.
Install
`happstack`
(more information
[here] (http://www.happstack.com/page/view-page-slug/2/download)).
In the same command prompt open as administrator in step 2 type
`cabal install happstack-server`
4.
Install
`acid-state`
. Again, in the same command prompt, type:
`cabal install acid-state`
5.
Compile the project:
If you have `make` installed on your system, you can go to the root directory
of the project (the directory containing the Makefile) and execute `make`.
This will do the job.
If you don't have `make` installed on your system, you can go inside the
the `src` directory and execute
`ghc --make Main.hs -o rewardsystem`
**Observation:** the binary named _rewardsystem_, in this case, must be
manually moved to the root directory (since it will be inside the src
directory). This is necessary because inside the root directory exists a
directory named _tmp_, and this is mandatory for the execution of the
program.
**IMPORTANT NOTE: In the same folder than this executable must be a folder
named _tmp_, and the user who launches the executable must have permissions
to write in tmp**
6.
Execute _Server_ and play... It listens on port 8000. You can either use
curl or the browser to test it. See the section in which I include a DEMO
for further details.
##Demos
I include in this documentation four demos that might help for the compilation
and/or the execution of the program.
| Link | Description |
| ---- | ----------- |
|
[
youtube.com
](
youtube.com
)
| installation on ubuntu |
|
[
youtube.com
](
youtube.com
)
| installation on windows |
|
[
youtube.com
](
youtube.com
)
| execution on ubuntu |
|
[
youtube.com
](
youtube.com
)
| execution on windows |
##A demo
##TO-DO's
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment