mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-22 12:03:25 -04:00
(refactor) use sha256 instead of md5 for calendar summary
This commit is contained in:
parent
0c444ad1af
commit
96197e3f37
@ -64,7 +64,7 @@ const run = async (config: Config, baseUrl: string): Promise<void> => {
|
||||
const prev = fs.existsSync(prevPath) ? JSON.parse(fs.readFileSync(prevPath, 'utf-8')) : {};
|
||||
|
||||
const localEvents = (await import(`../locale/${config.locale}/calendar/events.ts`)).default;
|
||||
const current = buildCalendar(localEvents, process.env.NUXT_PUBLIC_BASE_URL!).buildSummary();
|
||||
const current = await buildCalendar(localEvents, process.env.NUXT_PUBLIC_BASE_URL!).buildSummary();
|
||||
const changedYears = new Set();
|
||||
for (const day of Object.keys(current)) {
|
||||
const year = day.substring(0, 4);
|
||||
|
@ -1,10 +1,8 @@
|
||||
import type { EventAttributes } from 'ics';
|
||||
import md5 from 'js-md5';
|
||||
import nepali from 'nepali-calendar-js';
|
||||
import { v5 as uuid5 } from 'uuid';
|
||||
|
||||
import { newDate } from '../helpers.ts';
|
||||
|
||||
import { newDate, sha256 } from '~/src/helpers.ts';
|
||||
import type { Translator } from '~/src/translator.ts';
|
||||
|
||||
export class Day {
|
||||
@ -448,16 +446,13 @@ export class Calendar {
|
||||
}
|
||||
}
|
||||
|
||||
buildSummary(): Record<string, string> {
|
||||
async buildSummary(): Promise<Record<string, string>> {
|
||||
const summary: Record<string, string> = {};
|
||||
for (const year of this.getAllYears()) {
|
||||
for (let month = 1; month <= 12; month++) {
|
||||
for (const day of iterateMonth(year.year, month)) {
|
||||
const events = [];
|
||||
for (const event of year.eventsByDate[day.toString()] || []) {
|
||||
events.push(event.name);
|
||||
}
|
||||
summary[day.toString()] = md5(JSON.stringify(events));
|
||||
const events = (year.eventsByDate[day.toString()] || []).map((event) => event.name);
|
||||
summary[day.toString()] = await sha256(JSON.stringify(events));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user