Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
madvas committed Dec 29, 2016
1 parent 59bca84 commit 4ef8b1d
Show file tree
Hide file tree
Showing 41 changed files with 3,305 additions and 319 deletions.
2 changes: 1 addition & 1 deletion project.clj
Expand Up @@ -23,7 +23,7 @@
[org.clojure/clojurescript "1.9.293"]
[print-foo-cljs "2.0.3"]
[re-frame "0.9.0"]
[reagent "0.6.0" :exclusions [cljsjs/react cljsjs/react-dom]]]
[reagent "0.6.1p-SNAPSHOT" :exclusions [cljsjs/react cljsjs/react-dom]]]

:plugins [[lein-auto "0.1.2"]
[lein-cljsbuild "1.1.4"]
Expand Down
15 changes: 11 additions & 4 deletions resources/public/contracts/src/ethlanceSearch.sol
Expand Up @@ -33,7 +33,7 @@ contract EthlanceSearch {
uint8Filters[3] = hoursPerWeeks;
jobIds = JobLibrary.searchJobs(ethlanceDB, categoryId, skills, uint8Filters, uintArgs);
jobIds = SharedLibrary.findTopNValues(jobIds, uintArgs[5] + uintArgs[6]);
return SharedLibrary.getPage(jobIds, uintArgs[5], uintArgs[6]);
return SharedLibrary.getPage(jobIds, uintArgs[5], uintArgs[6], false);
}

function searchFreelancers(
Expand All @@ -46,16 +46,23 @@ contract EthlanceSearch {
uint countryId,
uint languageId,
uint offset,
uint limit
uint limit,
uint seed
)
constant returns
(
uint[] userIds)
{
userIds = UserLibrary.searchFreelancers(ethlanceDB, categoryId, skills, minAvgRating, minRatingsCount,
minHourlyRate, maxHourlyRate, countryId, languageId);
userIds = SharedLibrary.getPage(userIds, offset, limit);

if (userIds.length > 0) {
if (offset > userIds.length) {
return SharedLibrary.take(0, userIds);
} else if (offset + limit > userIds.length) {
limit = userIds.length - offset;
}
userIds = SharedLibrary.getPage(userIds, (seed + offset) % userIds.length, limit, true);
}
return userIds;
}
}
20 changes: 14 additions & 6 deletions resources/public/contracts/src/sharedLibrary.sol
Expand Up @@ -94,23 +94,31 @@ library SharedLibrary {
}


function getPage(uint[] array, uint offset, uint limit) internal returns (uint[] result) {
function getPage(uint[] array, uint offset, uint limit, bool cycle) internal returns (uint[] result) {
uint j = 0;
if (offset >= array.length) {
uint length = array.length;
if (offset >= length || limit == 0) {
return result;
}
if (limit == 0) {
return array;
}

result = new uint[](limit);
for (uint i = offset; i < (offset + limit); i++) {
if (array.length == i) {
if (length == i) {
break;
}
result[j] = array[i];
j++;
}

if (cycle && j < limit) {
for (i = 0; i <= limit - j; i++) {
if (length == j) {
break;
}
result[j] = array[i];
j++;
}
}
return take(j, result);
}

Expand Down
7 changes: 5 additions & 2 deletions resources/public/css/ethlance.css

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions resources/public/css/ethlance.main.css.map

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions resources/public/images/arrow.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/public/images/badge.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/public/images/bg1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4ef8b1d

Please sign in to comment.