comparison scan.pl @ 25:51a35c3d057e

cached 12 hours for user account.
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Fri, 10 Oct 2008 03:20:05 +0800
parents 552528bb4917
children 704d76b67670
comparison
equal deleted inserted replaced
24:93d4e6ffe330 25:51a35c3d057e
5 5
6 package main; 6 package main;
7 sub saveCities 7 sub saveCities
8 { 8 {
9 my ($island, @cities) = @_; 9 my ($island, @cities) = @_;
10
11 die ("empty cities list.\n") if ($#cities == -1);
10 12
11 foreach my $city (@cities) 13 foreach my $city (@cities)
12 { 14 {
13 $city->{island} = $island; 15 $city->{island} = $island;
14 $city->{'time'} = time; 16 $city->{'time'} = time;
25 } else { 27 } else {
26 Ikariam::Cities->insert($city); 28 Ikariam::Cities->insert($city);
27 } 29 }
28 30
29 printf("city %d %s saved\n", $city->{cityId}, $city->{cityname}); 31 printf("city %d %s saved\n", $city->{cityId}, $city->{cityname});
30 if(my $user = Ikariam::User->retrieve($city->{user})) 32 my $user = Ikariam::User->retrieve($city->{user});
31 { 33 if(!defined($user) || $user->time le (time - 60*60*12)) {
32 if($user->time le (time - 60*60*12)) { 34 # Download user profile.
33 # Download user profile. 35 foreach my $x (qw/score army_score_main trader_score_secondary/)
34 foreach my $x (qw/score army_score_main trader_score_secondary/) 36 {
35 { 37 my $users = $::i->viewScore($x, $city->{owner}, 0);
36 my $users = $::i->viewScore($x, $city->{owner}, 0); 38 saveUser($users);
37 saveUser($users);
38 }
39 } 39 }
40 } 40 }
41 } 41 }
42 } 42 }
43 43