/
ethlanceSearch.sol
68 lines (63 loc) · 2.08 KB
/
ethlanceSearch.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
pragma solidity ^0.4.4;
import "userLibrary.sol";
import "jobLibrary.sol";
import "contractLibrary.sol";
import "invoiceLibrary.sol";
import "categoryLibrary.sol";
import "skillLibrary.sol";
contract EthlanceSearch {
address public ethlanceDB;
function EthlanceSearch(address _ethlanceDB) {
if(_ethlanceDB == 0x0) throw;
ethlanceDB = _ethlanceDB;
}
function searchJobs(
uint categoryId,
uint[] skills,
uint8[] paymentTypes,
uint8[] experienceLevels,
uint8[] estimatedDurations,
uint8[] hoursPerWeeks,
uint[] uintArgs
)
constant public returns (uint[] jobIds)
{
uint8[][4] memory uint8Filters; // To avoid compiler stack too deep error
uint8Filters[0] = paymentTypes;
uint8Filters[1] = experienceLevels;
uint8Filters[2] = estimatedDurations;
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], false);
}
function searchFreelancers(
uint categoryId,
uint[] skills,
uint8 minAvgRating,
uint minRatingsCount,
uint minHourlyRate,
uint maxHourlyRate,
uint countryId,
uint languageId,
uint offset,
uint limit,
uint seed
)
constant returns
(
uint[] userIds)
{
userIds = UserLibrary.searchFreelancers(ethlanceDB, categoryId, skills, minAvgRating, minRatingsCount,
minHourlyRate, maxHourlyRate, countryId, languageId);
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;
}
}