PRO eis_time_component_cleanup

;1. Use v1 of planning and planning_db
;2. Run tlb_db_cleanup
;3. Run ohno - making sure to update eis_timeline_db.dbd to 



;replace call to astrolib
    defsysv,'!DEBUG', 0
    defsysv,'!TEXTUNIT', 0
    defsysv,'!PRIV', 2
    defsysv,'!TEXTOUT', EXIST = EXIST


zdbase = fix_zdbase(/USER)
status = eis_open_db(/TIME, /UPDATE)
items  = db_info('entries')
print,STRJOIN(['number of items = ',STRCOMPRESS(items[0])],/SINGLE)

zero_r = -1

print,'i   r'


FOR i = 0, items[0]    DO BEGIN

    zdbase = fix_zdbase(/USER)
    status = eis_open_db(/TIME, /UPDATE)
    r      = dbfind('SEQUENCE_ID = ' + STRCOMPRESS(i,/REMOVE_ALL) ,         $
                           count = count , /SILENT)

    IF (r[0] EQ 0) THEN BEGIN
        CASE zero_r[0] OF
            -1   : zero_r = i
            ELSE : zero_r = [zero_r , i]
        ENDCASE
    ENDIF

    i_str  = STRING(format='(A-4)',STRCOMPRESS(i   ,/REMOVE))
    r_str  = STRING(format='(A-4)',STRCOMPRESS(r[0],/REMOVE))

    num_comp = STRJOIN([i_str,r_str],/single)
    print,num_comp

ENDFOR

;stop
; Make sure i = 0 -> r = no entries
; Hence, do loop over 1 to items - 1
; Make sure each r has 1 value, and that it equals i
IF (zero_r[0] NE -1) THEN BEGIN
    status = eis_open_db(/TIME, /UPDATE)

    FOR i = 0, N_ELEMENTS(zero_r) - 1 DO BEGIN

        dbput,'SEQUENCE_ID',zero_r[i] ,zero_r[i]

    ENDFOR
ENDIF


END
