Subversion Repositories SmartDukaan

Rev

Rev 37335 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37335 Rev 37337
Line 896... Line 896...
896
        });
896
        });
897
    });
897
    });
898
 
898
 
899
    // ------------------------------------------------------- ingest status polling
899
    // ------------------------------------------------------- ingest status polling
900
    //
900
    //
901
    // Upload and parsing run in different processes: the portal stores the PDF as
901
    // Parsing runs on a background thread in this application and takes seconds, but
902
    // DRAFT, and the cron job claims and parses it on its own schedule. Without this
902
    // it is still asynchronous, so the screen must say where it has got to. Without
903
    // the screen looks identical before and after a successful ingest, so a reviewer
-
 
904
    // has no way to tell "not parsed yet" from "parsed and produced nothing".
903
    // this a reviewer cannot tell "not parsed yet" from "parsed and produced nothing".
905
 
904
 
906
    var PENDING_STATES = { DRAFT: 'queued for parsing', PROCESSING: 'parsing now' };
905
    var PENDING_STATES = { DRAFT: 'about to parse', PROCESSING: 'parsing now' };
907
 
906
 
908
    function selectedDoc() {
907
    function selectedDoc() {
909
        var id = currentDocumentId();
908
        var id = currentDocumentId();
910
        if (!id) { return null; }
909
        if (!id) { return null; }
911
        for (var i = 0; i < (state.documents || []).length; i++) {
910
        for (var i = 0; i < (state.documents || []).length; i++) {
Line 921... Line 920...
921
        var doc = selectedDoc();
920
        var doc = selectedDoc();
922
        if (!doc) { box.empty(); return; }
921
        if (!doc) { box.empty(); return; }
923
 
922
 
924
        if (PENDING_STATES[doc.status]) {
923
        if (PENDING_STATES[doc.status]) {
925
            box.html('<span class="oc-pill oc-pill-warn">' + esc(PENDING_STATES[doc.status])
924
            box.html('<span class="oc-pill oc-pill-warn">' + esc(PENDING_STATES[doc.status])
926
                + '</span> <span class="oc-num">the ingest job runs every 5 minutes; '
925
                + '</span> <span class="oc-num">usually a few seconds; '
927
                + 'this refreshes itself</span>');
926
                + 'this refreshes itself</span>');
928
        } else if (doc.status === 'FAILED') {
927
        } else if (doc.status === 'FAILED') {
929
            box.html('<span class="oc-pill oc-pill-danger">ingest failed</span> '
928
            box.html('<span class="oc-pill oc-pill-danger">ingest failed</span> '
930
                + '<span class="oc-num">' + esc(doc.ingestError || 'no reason recorded')
929
                + '<span class="oc-num">' + esc(doc.ingestError || 'no reason recorded')
931
                + '</span>');
930
                + '</span>');
Line 957... Line 956...
957
                    loadRows();
956
                    loadRows();
958
                    return;
957
                    return;
959
                }
958
                }
960
                schedulePoll();
959
                schedulePoll();
961
            }, function () { schedulePoll(); });   // transient failure - keep waiting
960
            }, function () { schedulePoll(); });   // transient failure - keep waiting
962
        }, 15000);
961
        }, 3000);
963
    }
962
    }
964
 
963
 
965
    // direct navigation: the fragment is already on the page
964
    // direct navigation: the fragment is already on the page
966
    if (root().length > 0) {
965
    if (root().length > 0) {
967
        loadRows();
966
        loadRows();