slartyblartfast (slartyblartfast) wrote in changelog,
slartyblartfast
slartyblartfast
changelog

[ljcom] r8412: LJSUP-5750: Intel Lifescoop at QotD: add...

Committer: mchernyshev
LJSUP-5750: Intel Lifescoop at QotD: add new IDs mapping for the new campaign
- added hook to hide service tag from user for qotd;
- obtain mtid from service tag;
- URLs moved from worker to config;
- worker option --test removed.
U   trunk/bin/worker/qotd-wepc
U   trunk/cgi-bin/LJ/Hooks/QotD.pm
Modified: trunk/bin/worker/qotd-wepc
===================================================================
--- trunk/bin/worker/qotd-wepc	2010-04-01 03:58:44 UTC (rev 8411)
+++ trunk/bin/worker/qotd-wepc	2010-04-01 04:17:09 UTC (rev 8412)
@@ -11,23 +11,6 @@
 use base 'LJ::NewWorker::TheSchwartz';
 sub capabilities { return ('LJ::Worker::QotDWePC', 'LJ::Worker::QotDIntel'); };
 
-sub help {
-    my $self = shift;
-    return
-        $self->SUPER::help() .
-        "-t | --test        use test url for submit information\n";
-}
-
-my $debug_mode = 0;
-
-sub options {
-    my $self = shift;
-    return (
-        'test|t' => \$debug_mode,
-        $self->SUPER::options(),
-    );
-}
-
 __PACKAGE__->start;
 
 package LJ::Worker::QotDWePC;
@@ -51,18 +34,12 @@
         die "qotd-wepc: No poster for entry $journal:$jitemid";
     }
     
-#    my $picid = $poster->{defaultpicid};
-#    my $default_userpic_img = ($picid) ? "$LJ::USERPIC_ROOT/$picid/$poster->{userid}" : ''; 
-
-    my $url = ($debug_mode) ? 
-        "http://beta-wepc.cm.fmpub.net/api/lj" : 
-        "http://www.wepc.com/api/lj";
-    my $request = POST($url,
+    my $request = POST($LJ::QOTD_WEPC_URL || 'http://www.wepc.com/api/lj',
         [ 
             username => $journal->username,
             content  => $entry_text,
             email => $user_email,
-            qid => ($debug_mode) ? 998 : $qid,
+            qid => $qid,
             guid => $entry->url,
             #avatar => $default_userpic_img,
             rlink => $poster->profile_url,
@@ -89,37 +66,47 @@
     my $entry_text = $entry->event_raw;
     $entry_text =~ s#<lj-template name="qotd" id="\d+" />##g;
 
+    my $qotd = LJ::QotD->get_single_question($qid);
+    my $tags = LJ::Widget::QotD->tags_text($qotd);
+
+    my $entry_id = 0;
+
+    if ($tags =~ /mtid:(\d+)/) {
+        $entry_id = $1;
+    }
+
+    unless ($entry_id) {    
+
+        ## livejournal qotd id --> mt id
+        my %entry_id_map = (
+            1161    =>  528,
+            1162    =>  531,
+            1202    =>  643,
+            1203    =>  644,
+            1218    =>  986,
+            1219    =>  989,
+            1220    =>  1053,
+            1221    =>  1054,
+            1375    =>  1578,   ## 2/22
+            1377    =>  1579,   ## 2/23
+            1379    =>  1583,   ## 3/15
+            1381    =>  1585,   ## 3/16
+        );
+
+        $entry_id = ($entry_id_map{$qid}) ?
+            $entry_id_map{$qid} : die "No MT ID for qotd id #$qid";
+    }
+
     my $ua = LWP::UserAgent->new;
 
     my $poster = $entry->poster;
     unless ($poster) {
         die "qotd-wepc: No poster for entry $journal:$jitemid";
     }
-    
-    my $url = ($debug_mode) ? 
-        "http://andrew.dev2.apperceptive.com/mt/mt-comments.cgi" : 
-        "http://mt.lifescoop.cm.fmpub.net/cgi-bin/mt/mt-6abB7h2-comments.cgi";
 
-    ## livejournal qotd id --> mt id
-    my %entry_id_map = (
-        1161    =>  528,
-        1162    =>  531,
-        1202    =>  643,
-        1203    =>  644,
-        1218    =>  986,
-        1219    =>  989,
-        1220    =>  1053,
-        1221    =>  1054,
-        1375    =>  1578,   ## 2/22
-        1377    =>  1579,   ## 2/23
-        1379    =>  1583,   ## 3/15
-        1381    =>  1585,   ## 3/16
-    );
-    my $entry_id =  ($debug_mode)         ? 1 :
-                    ($entry_id_map{$qid}) ? $entry_id_map{$qid} :
-                    die "No MT ID for qotd id #$qid";
-                    
-    my $request = POST($url,
+    my $request = POST(
+        $LJ::QOTD_INTEL_URL ||
+            'http://mt.lifescoop.cm.fmpub.net/cgi-bin/mt/mt-6abB7h2-comments.cgi',
         [ 
             author => $journal->username,
             url => $entry->url,
@@ -139,4 +126,3 @@
     $job->completed;
 }
 
-

Modified: trunk/cgi-bin/LJ/Hooks/QotD.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/QotD.pm	2010-04-01 03:58:44 UTC (rev 8411)
+++ trunk/cgi-bin/LJ/Hooks/QotD.pm	2010-04-01 04:17:09 UTC (rev 8412)
@@ -137,6 +137,12 @@
     return $out;
 });
 
+# Don't show service tag with mt id to user.
+LJ::register_hook("qotd_modify_tags", sub {
+    my $tags = shift;
+    $$tags = join(',', grep { ! /mtid:\d+/ } split(/,/, $$tags)) if $tags;
+});
+
 LJ::register_hook("postpost", sub {
     my $opts = shift;
 

Tags: ljcom, pm, slartyblartfast
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments