PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/DDG/Spice/FirstRobotics/TeamInfo.pm

http://github.com/duckduckgo/zeroclickinfo-spice
Perl | 41 lines | 23 code | 14 blank | 4 comment | 3 complexity | 371738879288f1783845d8a2c989322b MD5 | raw file
Possible License(s): Apache-2.0
  1. package DDG::Spice::FirstRobotics::TeamInfo;
  2. # ABSTRACT: Get info on teams in the FIRST Robotics Competition
  3. use DDG::Spice;
  4. spice is_cached => 1;
  5. spice proxy_cache_valid => "200 1d"; # defaults to this automatically
  6. spice wrap_jsonp_callback => 1;
  7. spice to => 'https://www.thebluealliance.com/api/v2/team/frc$1?X-TBA-App-Id=duckduckgo:search-engine:1';
  8. # Obtain the years a team has competed
  9. spice alt_to => {
  10. years_competed => {
  11. is_cached => 1,
  12. proxy_cache_valid => "200 1d",
  13. to => 'https://www.thebluealliance.com/api/v2/team/frc$1/years_participated?X-TBA-App-Id=duckduckgo:search-engine:1'
  14. }
  15. };
  16. triggers startend => 'frc', 'frc team', 'first robotics team', 'first robotics competition';
  17. handle remainder_lc => sub {
  18. # only continue if the query contains digits
  19. return unless /\d+/;
  20. # guard against "top 10 teams" type queries
  21. return if ($req->query_clean =~ /\d+\s*(?:top|best|highest)/
  22. || $req->query_clean =~ /(?:top|best|highest(?:\sranked)?)\s*\d+/);
  23. s/\D+//g; # strip all non-digits, leaving a team number for the API
  24. return $_ if $_;
  25. return;
  26. };
  27. 1;