Ver Fonte

Fix timestamp returned when doing full dumps

Jordi Boggiano há 5 anos atrás
pai
commit
2afcff7cf3

+ 2 - 0
app/Resources/TwigBundle/views/Exception/error404.html.twig

@@ -11,3 +11,5 @@
     </section>
 </section>
 {% endblock %}
+
+{% block analytics %}{% endblock %}

+ 3 - 3
src/Packagist/WebBundle/Controller/PackageController.php

@@ -77,9 +77,11 @@ class PackageController extends Controller
      */
     public function updatedSinceAction(Request $req)
     {
+        $lastDumpTime = $this->get('snc_redis.default_client')->get('last_metadata_dump_time') ?: (time() - 60);
+
         $since = $req->query->get('since');
         if (!$since) {
-            return new JsonResponse(['error' => 'Missing "since" query parameter with the latest timestamp you got from this endpoint'], 400);
+            return new JsonResponse(['error' => 'Missing "since" query parameter with the latest timestamp you got from this endpoint', 'timestamp' => $lastDumpTime], 400);
         }
 
         try {
@@ -93,8 +95,6 @@ class PackageController extends Controller
 
         $names = $repo->getPackageNamesUpdatedSince($since);
 
-        $lastDumpTime = $this->get('snc_redis.default_client')->get('last_metadata_dump_time') ?: (time() - 60);
-
         return new JsonResponse(['packageNames' => $names, 'timestamp' => $lastDumpTime]);
     }
 

+ 3 - 1
src/Packagist/WebBundle/Package/SymlinkDumper.php

@@ -492,7 +492,9 @@ class SymlinkDumper
                 }
             }
 
-            $maxDumpTime = max($maxDumpTime, strtotime($dt));
+            if ($dt !== '2100-01-01 00:00:00') {
+                $maxDumpTime = max($maxDumpTime, strtotime($dt));
+            }
         }
 
         if ($maxDumpTime !== 0) {

+ 2 - 0
src/Packagist/WebBundle/Resources/views/layout.html.twig

@@ -215,6 +215,7 @@
         <script src="https://cdn.jsdelivr.net/npm/instantsearch.js@2.7.4/dist/instantsearch.min.js"></script>
         <script src="{{ asset('bundles/packagistweb/js/search.js') }}"></script>
 
+        {%- block analytics %}
         {%- if not app.debug and google_analytics.ga_key %}
         <script>
             (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@@ -227,6 +228,7 @@
             ga('send', 'pageview');
         </script>
         {%- endif %}
+        {%- endblock %}
 
         {% block scripts %}{% endblock %}
     </body>