autofixDiffFilePatch.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import {
  2. DiffFileType,
  3. DiffLineType,
  4. FilePatch,
  5. } from 'sentry/components/events/autofix/types';
  6. export function AutofixDiffFilePatch(params: Partial<FilePatch> = {}): FilePatch {
  7. return {
  8. added: 1,
  9. path: 'src/sentry/processing/backpressure/memory.py',
  10. removed: 1,
  11. source_file: 'src/sentry/processing/backpressure/memory.py',
  12. target_file: 'src/sentry/processing/backpressure/memory.py',
  13. type: DiffFileType.MODIFIED,
  14. hunks: [
  15. {
  16. lines: [
  17. {
  18. line_type: DiffLineType.CONTEXT,
  19. diff_line_no: 6,
  20. source_line_no: 47,
  21. target_line_no: 47,
  22. value: ' # or alternatively: `used_memory_rss`?\n',
  23. },
  24. {
  25. line_type: DiffLineType.CONTEXT,
  26. diff_line_no: 7,
  27. source_line_no: 48,
  28. target_line_no: 48,
  29. value: ' memory_used = info.get("used_memory", 0)\n',
  30. },
  31. {
  32. line_type: DiffLineType.CONTEXT,
  33. diff_line_no: 8,
  34. source_line_no: 49,
  35. target_line_no: 49,
  36. value: ' # `maxmemory` might be 0 in development\n',
  37. },
  38. {
  39. line_type: DiffLineType.REMOVED,
  40. diff_line_no: 9,
  41. source_line_no: 50,
  42. target_line_no: null,
  43. value:
  44. ' memory_available = info.get("maxmemory", 0) or info["total_system_memory"]\n',
  45. },
  46. {
  47. line_type: DiffLineType.ADDED,
  48. diff_line_no: 10,
  49. source_line_no: null,
  50. target_line_no: 50,
  51. value:
  52. ' memory_available = info.get("maxmemory", 0) or info.get("total_system_memory", 0)\n',
  53. },
  54. {
  55. line_type: DiffLineType.CONTEXT,
  56. diff_line_no: 11,
  57. source_line_no: 51,
  58. target_line_no: 51,
  59. value: '\n',
  60. },
  61. {
  62. line_type: DiffLineType.CONTEXT,
  63. diff_line_no: 12,
  64. source_line_no: 52,
  65. target_line_no: 52,
  66. value: ' return ServiceMemory(node_id, memory_used, memory_available)\n',
  67. },
  68. {
  69. line_type: DiffLineType.CONTEXT,
  70. diff_line_no: 13,
  71. source_line_no: 53,
  72. target_line_no: 53,
  73. value: '\n',
  74. },
  75. ],
  76. section_header:
  77. 'def get_memory_usage(node_id: str, info: Mapping[str, Any]) -> ServiceMemory:',
  78. source_length: 7,
  79. source_start: 47,
  80. target_length: 7,
  81. target_start: 47,
  82. },
  83. ],
  84. ...params,
  85. };
  86. }