---
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .NAME }}-backfiller
  namespace: {{ .NAMESPACE }}
data:
  rpcProviders.json: |-
---
apiVersion: batch/v1
kind: Job
metadata:
  name: {{ .NAME }}-backfiller
  namespace: {{ .NAMESPACE }}
spec:
  template:
    metadata:
      labels:
        app: {{ .NAME }}-backfiller
    spec:
      restartPolicy: Never
      terminationGracePeriodSeconds: 40
      containers:
        - name: {{ .NAME }}-backfiller
          image: {{ .IMAGE_NAME }}
          imagePullPolicy: Always
          env:
            - name: MONGODB_URI
              valueFrom:
                secretKeyRef:
                  name: mongodb
                  key: mongo-uri
            - name: MONGODB_DATABASE
              valueFrom:
                configMapKeyRef:
                  name: config
                  key: mongo-database
          command: ["/tx-tracker"]
          args:
            - backfiller
            - vaas
            - --mongo-uri
            - "$(MONGODB_URI)"
            - --mongo-database
            - "$(MONGODB_DATABASE)"
            - --rpc-providers-path
            - "/opt/tx-tracker/config/rpcProviders.json"
            - --p2p-network
            - "{{ .P2P_NETWORK }}"
            - --start-time
            - "2023-04-19T00:00:00Z"
            - --end-time
            - "2023-04-21T00:00:00Z"
            - --emitter-chain
            - "1"
            - --page-size
            - "1000"
            - --requests-per-minute
            - "12"
            - --num-workers
            - "10"
            - --overwrite
            - --disable-db-upsert
          volumeMounts:
            - name: config-volume
              mountPath: /opt/tx-tracker/config
      volumes:
        - name: config-volume
          configMap:
            name: {{ .NAME }}-backfiller
            items:
              - key: rpcProviders.json
                path: rpcProviders.json          