Skip to content

Commit

Permalink
POC-885: fixed Lists not getting generated due to weeks overlap in th… (
Browse files Browse the repository at this point in the history
#1776)

* POC-885: fixed Lists not getting generated due to weeks overlap in the new and past year

* POC-885: fixed missing label in year week

* updated github actions version

* remove custom getISOWeek function
  • Loading branch information
Kipkemoii authored Jan 7, 2025
1 parent d60b7f7 commit f2bb000
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ name: Ng2-amrs CI

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand Down Expand Up @@ -40,7 +39,7 @@ jobs:
- name: Build prod
run: npm run build-prod
- name: Upload build files to artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: build-files
path: dist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import * as _ from 'lodash';
import { Subscription } from 'rxjs';
import { PreAppointmentOutreachResourceService } from 'src/app/etl-api/pre-appointment-outreach-resource.service';
import { getISOWeek } from 'date-fns';

interface ReportParams {
locationUuids: string;
Expand Down Expand Up @@ -53,7 +54,7 @@ export class PreAppointmentOutreachComponent implements OnInit {
private route: ActivatedRoute
) {
const today = new Date();
const currentWeek = this.getISOWeek(today);
const currentWeek = getISOWeek(today);
const currentYear = today.getFullYear();
const startYear = 2023;
const numberOfWeeks = 52; // Set the maximum number of weeks to 52
Expand Down Expand Up @@ -361,21 +362,4 @@ export class PreAppointmentOutreachComponent implements OnInit {
(day - 1) * 24 * 60 * 60 * 1000
);
}

private getISOWeek(date: Date): number {
const firstDayOfYear = new Date(date.getFullYear(), 0, 1);
const daysOffset = firstDayOfYear.getDay() - 1;
const firstMondayOfYear = new Date(
firstDayOfYear.getFullYear(),
0,
1 + (daysOffset > 0 ? 7 - daysOffset : 0)
);

const daysPassed = Math.floor(
(date.getTime() - firstMondayOfYear.getTime()) / 86400000
);
const weeksPassed = Math.floor(daysPassed / 7) + 1;

return weeksPassed;
}
}

0 comments on commit f2bb000

Please sign in to comment.