This repo is to submit my code exercise to Zendesk. Zendesk describes that it is fine for me to use Public repo for my exercise.
-
For me this is malformed ISO8601 format,
"2016-05-21T11:10:28 -10:00"
but assumed that it is on purpose.- There should not be
space
before timezone adjustment,-10:00
- There should not be
-
I decided Optional fields myself based on the given data. I assumed that fields having
null
value is optional ones.-
Users
alias
: Option[Alias],verified
: Option[Verified],locale
: Option[Locale],timezone
: Option[Timezone],email
: Option[Email],organizationId
: Option[OrganizationId],
-
Organizations
- None
-
Tickets
type
: Option[Type],description
: Option[Description],assigneeId
: Option[AssigneeId],organizationId
: Option[OrganizationId],dueAt
: Option[ZenDateTime],
-
-
For this statement,
The user should also be able to search for empty values, e.g. where description is empty
. In the data, description is nullable value so assumed that only nullable value could searchable withEmpty string value
, which is stated at #2. -
I assumed that my UX does not have to be the same as the provided sample.
- I wanted to display the searchable fields for the object users are selected.
- Screenshot is attached at Appendix
-
Search value is case-sensitive and Search term(field) is case-insensitive.
Enter search term
is case-insensitiveEnter search value
is case-sensitive
- Circe to parse Json data files; users.json, tickets.json, and organizations.json
- Cats for general FP type classes like Either.
- Cats-Effect for IO Monad
- Spec2 this is just personal preference. I found that this style is better than scala-test but could be opinionated
- Scala Check for Simple Property Check
- FastParser to parse Console Input, Using Regex makes code quit hard understand
In the job description, FP is desired skill so thought that I could do my best with FP.
Except a few codes almost all codes are pure; I did not use mock for testing.
Exceptions are
- Read JSON data files
- Creating Database data structure.
- Main class.
I have used these two Scala class based on this scala doc for BigO performance
- Either mutable or immutable HashMap
- Vector
-
Throughput
- Description mentioned that I could assume Memory could store all data so this will not be tested.
- It does not matter how much text data will be flushed into IO.
-
Latency; Result was acceptable, I felt less than 1 sec delay.
- Search time should not BigO(N)
- I have created 3 files under
./data
directory which have 150 times more data than the given data.- many-users.json
- many-tickets.json
- many-organizations.json
JAVA_OPTS="-Xmx2g" scala target/scala-2.13/zendesk.jar data/many-users.json data/many-organizations.json data/many-tickets.json
- need to increase JVM heapsize; Search Users with
organizationId
andempty string
.
- need to increase JVM heapsize; Search Users with
auto/run data/many-users.json data/many-organizations.json data/many-tickets.json
This is due to download sbt
and libraries
so please be patient.
sometime after running your test from docker the file owner tend to be changed as root
This command will fix the issue
sudo chown -r $USER:$USER .
- Install Open JDK 8u222
- Install sbt 1.3.6
- Scala 2.13.1
- Execute
Commands
below for either test or execute app
sbt clean test
-
sbt clean assembly
-
scala target/scala-2.13/zendesk.jar <optional users data file path> <optional organizations data file path> <optional tickets data file path>
- when optional params are not provided the default data files are used under
./data
directory- users.json
- tickets.json
- organizations.json
- when optional params are not provided the default data files are used under
- Install Latest Docker
- Install Docker Compose
- Use docker container,
auto/dev-environment
- Execute `Commands** below for either test or execute app
auto/dev-environment
auto/test
auto/run <optional users data file path> <optional organizations data file path> <optional tickets data file path>