MCPcopy
hub / github.com/uber/aresdb / initDatePickModal

Function initDatePickModal

api/ui/debug/js/purge.js:62–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60}
61
62function initDatePickModal() {
63 $('#start-batch-pick').datepicker();
64 $('#end-batch-pick').datepicker();
65 $('#date-pick-modal').on('show.bs.modal', function (event) {
66 var button = $(event.relatedTarget);
67 var table = button.data('table');
68 var shard = button.data('shard');
69 var modal = $(this);
70 modal.find('#purge-table-name').val(table);
71 modal.find('#purge-shard-id').val(shard)
72 });
73
74 $('#purge-button').click(function () {
75 var startDate = $('#start-batch-pick').val();
76 var endDate = $('#end-batch-pick').val();
77 var table = $('#purge-table-name').val();
78 var shard = $('#purge-shard-id').val();
79 var batchIDStart = 0;
80 var batchIDEnd = 0;
81 if (startDate) {
82 batchIDStart = Math.floor(new Date(startDate).getTime() / 1000 / 86400);
83 }
84 if (endDate) {
85 batchIDEnd = Math.floor(new Date(endDate).getTime() / 1000 / 86400);
86 }
87
88 if (batchIDEnd <= batchIDStart) {
89 alert("invalid batch start and end: [" + batchIDStart + "," + batchIDEnd + ")");
90 }
91
92 $.ajax({
93 url: "/schema/tables/{0}".format(table),
94 method: 'GET',
95 success: function (schema) {
96 var retentionDays = schema.config.recordRetentionInDays;
97 if (retentionDays > 0) {
98 var now = Math.floor(Date.now() / 1000 / 86400);
99 if (batchIDEnd >= (now - retentionDays)) {
100 if (!confirm('Are you sure to purge data within retention from ' + (now-retentionDays) + ' to ' + batchIDEnd)) {
101 return;
102 }
103 }
104 }
105 submitPurgeJob(table, shard, batchIDStart, batchIDEnd, false);
106 },
107 error: function (xhr) {
108 alert(xhr.responseText);
109 }
110 });
111 });
112}
113
114function submitPurgeJob(table, shard, batchIDStart, batchIDEnd, safePurge) {
115 $.ajax({

Callers 1

initSchedulerViewerFunction · 0.85

Calls 2

submitPurgeJobFunction · 0.85
nowMethod · 0.80

Tested by

no test coverage detected