Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RecrawlWarning.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // vendored from https://github.com/amasad/sane/blob/64ff3a870c42e84f744086884bf55a4f9c22d376/src/utils/recrawl-warning-dedupe.js
  2. 'use strict';
  3. class RecrawlWarning {
  4. constructor(root, count) {
  5. this.root = root;
  6. this.count = count;
  7. }
  8. static findByRoot(root) {
  9. for (let i = 0; i < this.RECRAWL_WARNINGS.length; i++) {
  10. const warning = this.RECRAWL_WARNINGS[i];
  11. if (warning.root === root) {
  12. return warning;
  13. }
  14. }
  15. return undefined;
  16. }
  17. static isRecrawlWarningDupe(warningMessage) {
  18. if (typeof warningMessage !== 'string') {
  19. return false;
  20. }
  21. const match = warningMessage.match(this.REGEXP);
  22. if (!match) {
  23. return false;
  24. }
  25. const count = Number(match[1]);
  26. const root = match[2];
  27. const warning = this.findByRoot(root);
  28. if (warning) {
  29. // only keep the highest count, assume count to either stay the same or
  30. // increase.
  31. if (warning.count >= count) {
  32. return true;
  33. } else {
  34. // update the existing warning to the latest (highest) count
  35. warning.count = count;
  36. return false;
  37. }
  38. } else {
  39. this.RECRAWL_WARNINGS.push(new RecrawlWarning(root, count));
  40. return false;
  41. }
  42. }
  43. }
  44. RecrawlWarning.RECRAWL_WARNINGS = [];
  45. RecrawlWarning.REGEXP =
  46. /Recrawled this watch (\d+) times, most recently because:\n([^:]+)/;
  47. module.exports = RecrawlWarning;