changeset 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 93d4e6ffe330
children d8117792c6f5
files scan.pl
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/scan.pl	Fri Oct 10 03:17:50 2008 +0800
+++ b/scan.pl	Fri Oct 10 03:20:05 2008 +0800
@@ -8,6 +8,8 @@
 {
     my ($island, @cities) = @_;
 
+    die ("empty cities list.\n") if ($#cities == -1);
+
     foreach my $city (@cities)
     {
         $city->{island} = $island;
@@ -27,15 +29,13 @@
         }
 
         printf("city %d %s saved\n", $city->{cityId}, $city->{cityname});
-        if(my $user = Ikariam::User->retrieve($city->{user}))
-        {
-            if($user->time le (time - 60*60*12)) {
-                # Download user profile.
-                foreach my $x (qw/score army_score_main trader_score_secondary/)
-                {
-                    my $users = $::i->viewScore($x, $city->{owner}, 0);
-                    saveUser($users);
-                }
+        my $user = Ikariam::User->retrieve($city->{user});
+        if(!defined($user) || $user->time le (time - 60*60*12)) {
+            # Download user profile.
+            foreach my $x (qw/score army_score_main trader_score_secondary/)
+            {
+                my $users = $::i->viewScore($x, $city->{owner}, 0);
+                saveUser($users);
             }
         }
     }