(year, team, school, conference, position)
| 17 | }; |
| 18 | |
| 19 | const getPicks = async (year, team, school, conference, position) => { |
| 20 | const filters = []; |
| 21 | const params = []; |
| 22 | let index = 1; |
| 23 | |
| 24 | if (year) { |
| 25 | filters.push(`dp.year = $${index}`); |
| 26 | params.push(year); |
| 27 | index++; |
| 28 | } |
| 29 | |
| 30 | if (team) { |
| 31 | filters.push(`LOWER(dt.location) = LOWER($${index})`); |
| 32 | params.push(team); |
| 33 | index++; |
| 34 | } |
| 35 | |
| 36 | if (school) { |
| 37 | filters.push(`LOWER(ct.school) = LOWER($${index})`); |
| 38 | params.push(school); |
| 39 | index++; |
| 40 | } |
| 41 | |
| 42 | if (conference) { |
| 43 | filters.push(`LOWER(c.abbreviation) = LOWER($${index})`); |
| 44 | params.push(conference); |
| 45 | index++; |
| 46 | } |
| 47 | |
| 48 | if (position) { |
| 49 | filters.push(`(LOWER(pos.name) = LOWER($${index}) OR LOWER(pos.abbreviation) = LOWER($${index}))`); |
| 50 | params.push(position); |
| 51 | index++; |
| 52 | } |
| 53 | |
| 54 | const filter = filters.length ? 'WHERE ' + filters.join(' AND ') : ''; |
| 55 | |
| 56 | let picks = await db.any(` |
| 57 | SELECT dp.college_id AS college_athlete_id, |
| 58 | dp.id AS nfl_athlete_id, |
| 59 | ct.id AS college_id, |
| 60 | ct.school AS college_team, |
| 61 | c.name AS conference, |
| 62 | dt.location AS nfl_team, |
| 63 | dp.year, |
| 64 | dp.overall, |
| 65 | dp.round, |
| 66 | dp.pick, |
| 67 | dp.name, |
| 68 | pos.name AS "position", |
| 69 | dp.height, |
| 70 | dp.weight, |
| 71 | dp.overall_rank, |
| 72 | dp.position_rank, |
| 73 | dp.grade, |
| 74 | h.city, |
| 75 | h.state, |
| 76 | h.country, |
nothing calls this directly
no outgoing calls
no test coverage detected