RocketChat/Rocket.Chat

View on GitHub
apps/meteor/server/models/raw/Sessions.ts

Summary

Maintainability
F
2 wks
Test Coverage

File Sessions.ts has 1508 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import type {
    ISession,
    UserSessionAggregation,
    DeviceSessionAggregation,
    OSSessionAggregation,
Severity: Major
Found in apps/meteor/server/models/raw/Sessions.ts - About 4 days to fix

    SessionsRaw has 33 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class SessionsRaw extends BaseRaw<ISession> implements ISessionsModel {
        private secondaryCollection: Collection<ISession>;
    
        constructor(db: Db, trash?: Collection<RocketChatRecordDeleted<ISession>>) {
            super(db, 'sessions', trash);
    Severity: Minor
    Found in apps/meteor/server/models/raw/Sessions.ts - About 4 hrs to fix

      Function aggregateSessionsAndPopulate has 103 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async aggregateSessionsAndPopulate({
              sort,
              search,
              offset = 0,
              count = 10,
      Severity: Major
      Found in apps/meteor/server/models/raw/Sessions.ts - About 4 hrs to fix

        Function getMatchOfLastMonthOrWeek has 89 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            getMatchOfLastMonthOrWeek({ year, month, day, type = 'month' }: DestructuredDateWithType): Filter<ISession> {
                let startOfPeriod;
        
                if (type === 'month') {
                    const pastMonthLastDay = new Date(year, month - 1, 0).getDate();
        Severity: Major
        Found in apps/meteor/server/models/raw/Sessions.ts - About 3 hrs to fix

          Function dailySessions has 88 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              dailySessions(
                  collection: Collection<ISession>,
                  { start, end }: DestructuredRange,
              ): AggregationCursor<
                  Pick<ISession, 'mostImportantRole' | 'userId' | 'day' | 'year' | 'month' | 'type'> & {
          Severity: Major
          Found in apps/meteor/server/models/raw/Sessions.ts - About 3 hrs to fix

            Function aggregateSessionsByUserId has 84 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async aggregateSessionsByUserId({
                    uid,
                    sort,
                    search,
                    offset = 0,
            Severity: Major
            Found in apps/meteor/server/models/raw/Sessions.ts - About 3 hrs to fix

              Function getUniqueUsersOfLastMonthOrWeek has 79 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async getUniqueUsersOfLastMonthOrWeek(
                      collection: Collection<ISession>,
                      { year, month, day, type = 'month' }: DestructuredDateWithType,
                  ): Promise<UserSessionAggregation[]> {
                      return collection
              Severity: Major
              Found in apps/meteor/server/models/raw/Sessions.ts - About 3 hrs to fix

                Function matchBasedOnDate has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const matchBasedOnDate = (start: DestructuredDate, end: DestructuredDate): Filter<ISession> => {
                    if (start.year === end.year && start.month === end.month) {
                        return {
                            year: start.year,
                            month: start.month,
                Severity: Major
                Found in apps/meteor/server/models/raw/Sessions.ts - About 2 hrs to fix

                  Function getUniqueUsersOfYesterday has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      async getUniqueUsersOfYesterday(
                          collection: Collection<ISession>,
                          { year, month, day }: DestructuredDate,
                      ): Promise<UserSessionAggregation[]> {
                          return collection
                  Severity: Major
                  Found in apps/meteor/server/models/raw/Sessions.ts - About 2 hrs to fix

                    Function getActiveUsersOfPeriodByDayBetweenDates has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async getActiveUsersOfPeriodByDayBetweenDates({ start, end }: DestructuredRange): Promise<
                            {
                                day: number;
                                month: number;
                                year: number;
                    Severity: Minor
                    Found in apps/meteor/server/models/raw/Sessions.ts - About 1 hr to fix

                      Function getUniqueOSOfLastMonthOrWeek has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          getUniqueOSOfLastMonthOrWeek(
                              collection: Collection<ISession>,
                              { year, month, day, type = 'month' }: DestructuredDateWithType,
                          ): Promise<OSSessionAggregation[]> {
                              return collection
                      Severity: Minor
                      Found in apps/meteor/server/models/raw/Sessions.ts - About 1 hr to fix

                        Function getUniqueOSOfYesterday has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            getUniqueOSOfYesterday(collection: Collection<ISession>, { year, month, day }: DestructuredDate): Promise<OSSessionAggregation[]> {
                                return collection
                                    .aggregate<OSSessionAggregation>([
                                        {
                                            $match: {
                        Severity: Minor
                        Found in apps/meteor/server/models/raw/Sessions.ts - About 1 hr to fix

                          Function getUniqueDevicesOfLastMonthOrWeek has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              async getUniqueDevicesOfLastMonthOrWeek(
                                  collection: Collection<ISession>,
                                  { year, month, day, type = 'month' }: DestructuredDateWithType,
                              ): Promise<DeviceSessionAggregation[]> {
                                  return collection
                          Severity: Minor
                          Found in apps/meteor/server/models/raw/Sessions.ts - About 1 hr to fix

                            Function getTotalOfSessionByHourAndDayBetweenDates has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                async getTotalOfSessionByHourAndDayBetweenDates({ start, end }: DateRange): Promise<
                                    {
                                        hour: number;
                                        day: number;
                                        month: number;
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/Sessions.ts - About 1 hr to fix

                              Function getUniqueDevicesOfYesterday has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  getUniqueDevicesOfYesterday(
                                      collection: Collection<ISession>,
                                      { year, month, day }: DestructuredDate,
                                  ): Promise<DeviceSessionAggregation[]> {
                                      return collection
                              Severity: Minor
                              Found in apps/meteor/server/models/raw/Sessions.ts - About 1 hr to fix

                                Function getBusiestTimeWithinHoursPeriod has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    async getBusiestTimeWithinHoursPeriod({ start, end, groupSize }: DateRange & { groupSize: number }): Promise<
                                        {
                                            hour: number;
                                            users: number;
                                        }[]
                                Severity: Minor
                                Found in apps/meteor/server/models/raw/Sessions.ts - About 1 hr to fix

                                  Function getTotalOfSessionsByDayBetweenDates has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      async getTotalOfSessionsByDayBetweenDates({ start, end }: DestructuredRange): Promise<
                                          {
                                              day: number;
                                              month: number;
                                              year: number;
                                  Severity: Minor
                                  Found in apps/meteor/server/models/raw/Sessions.ts - About 1 hr to fix

                                    Function getMatchOfLastMonthOrWeek has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        getMatchOfLastMonthOrWeek({ year, month, day, type = 'month' }: DestructuredDateWithType): Filter<ISession> {
                                            let startOfPeriod;
                                    
                                            if (type === 'month') {
                                                const pastMonthLastDay = new Date(year, month - 1, 0).getDate();
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts - About 35 mins to fix

                                    Cognitive Complexity

                                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                    A method's cognitive complexity is based on a few simple rules:

                                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                    • Code is considered more complex for each "break in the linear flow of the code"
                                    • Code is considered more complex when "flow breaking structures are nested"

                                    Further reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                        async getUniqueUsersOfLastWeek(): Promise<UserSessionAggregationResult> {
                                            const date = new Date();
                                            date.setDate(date.getDate() - 1);
                                    
                                            const year = date.getFullYear();
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 6 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1352..1371
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1409..1428

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 158.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                        async getUniqueOSOfLastWeek(): Promise<OSSessionAggregationResult> {
                                            const date = new Date();
                                            date.setDate(date.getDate() - 1);
                                    
                                            const year = date.getFullYear();
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 6 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1291..1310
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1352..1371

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 158.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                        async getUniqueDevicesOfLastWeek(): Promise<DeviceSessionAggregationResult> {
                                            const date = new Date();
                                            date.setDate(date.getDate() - 1);
                                    
                                            const year = date.getFullYear();
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 6 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1291..1310
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1409..1428

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 158.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 6 locations. Consider refactoring.
                                    Open

                                        async getUniqueDevicesOfLastMonth(): Promise<DeviceSessionAggregationResult> {
                                            const date = new Date();
                                            date.setDate(date.getDate() - 1);
                                    
                                            const year = date.getFullYear();
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 5 other locations - About 5 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1251..1269
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1271..1289
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1312..1330
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1373..1387
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1389..1407

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 153.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 6 locations. Consider refactoring.
                                    Open

                                        async getUniqueOSOfYesterday(): Promise<OSSessionAggregationResult> {
                                            const date = new Date();
                                            date.setDate(date.getDate() - 1);
                                    
                                            const year = date.getFullYear();
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 5 other locations - About 5 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1251..1269
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1271..1289
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1312..1330
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1332..1350
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1389..1407

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 153.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 6 locations. Consider refactoring.
                                    Open

                                        async getUniqueDevicesOfYesterday(): Promise<DeviceSessionAggregationResult> {
                                            const date = new Date();
                                            date.setDate(date.getDate() - 1);
                                    
                                            const year = date.getFullYear();
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 5 other locations - About 5 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1251..1269
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1271..1289
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1332..1350
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1373..1387
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1389..1407

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 153.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 6 locations. Consider refactoring.
                                    Open

                                        async getUniqueUsersOfLastMonth(): Promise<UserSessionAggregationResult> {
                                            const date = new Date();
                                            date.setDate(date.getDate() - 1);
                                    
                                            const year = date.getFullYear();
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 5 other locations - About 5 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1251..1269
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1312..1330
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1332..1350
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1373..1387
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1389..1407

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 153.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 6 locations. Consider refactoring.
                                    Open

                                        async getUniqueUsersOfYesterday(): Promise<UserSessionAggregationResult> {
                                            const date = new Date();
                                            date.setDate(date.getDate() - 1);
                                    
                                            const year = date.getFullYear();
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 5 other locations - About 5 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1271..1289
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1312..1330
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1332..1350
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1373..1387
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1389..1407

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 153.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 6 locations. Consider refactoring.
                                    Open

                                        async getUniqueOSOfLastMonth(): Promise<OSSessionAggregationResult> {
                                            const date = new Date();
                                            date.setDate(date.getDate() - 1);
                                    
                                            const year = date.getFullYear();
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 5 other locations - About 5 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1251..1269
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1271..1289
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1312..1330
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1332..1350
                                    apps/meteor/server/models/raw/Sessions.ts on lines 1373..1387

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 153.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                                    {
                                                        $or: [
                                                            {
                                                                year: { $gt: startOfPeriodObject.year },
                                                            },
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 2 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 88..103
                                    apps/meteor/server/models/raw/Sessions.ts on lines 104..119

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 86.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                                {
                                                    $or: [
                                                        {
                                                            year: { $gt: start.year },
                                                        },
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 2 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 104..119
                                    apps/meteor/server/models/raw/Sessions.ts on lines 493..508

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 86.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                                {
                                                    $or: [
                                                        {
                                                            year: { $lt: end.year },
                                                        },
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 2 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 88..103
                                    apps/meteor/server/models/raw/Sessions.ts on lines 493..508

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 86.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                            const groupOperator = {
                                                $group: {
                                                    _id: '$loginToken',
                                                    sessionId: {
                                                        $first: '$sessionId',
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 2 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 790..812

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 85.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                            const groupOperator = {
                                                $group: {
                                                    _id: '$loginToken',
                                                    sessionId: {
                                                        $first: '$sessionId',
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 2 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 895..917

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 85.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                            const [
                                                {
                                                    docs: sessions,
                                                    count: [{ total } = { total: 0 }],
                                                },
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 2 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 968..973

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 81.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                            const [
                                                {
                                                    docs: sessions,
                                                    count: [{ total } = { total: 0 }],
                                                },
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 2 hrs to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 842..847

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 81.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Identical blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        ): AggregationCursor<
                                            Pick<ISession, 'mostImportantRole' | 'userId' | 'day' | 'year' | 'month' | 'type'> & {
                                                time: number;
                                                sessions: number;
                                                devices: ISession['device'][];
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 1 hr to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 268..275

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 74.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Identical blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                            return collection.aggregate<
                                                Pick<ISession, 'mostImportantRole' | 'userId' | 'day' | 'year' | 'month' | 'type'> & {
                                                    time: number;
                                                    sessions: number;
                                                    devices: ISession['device'][];
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 1 hr to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 179..186

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 74.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        async logoutByloginTokenAndUserId({
                                            loginToken,
                                            userId,
                                            logoutBy,
                                        }: {
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 1 hr to fix
                                    apps/meteor/client/views/room/providers/hooks/useChatMessagesInstance.ts on lines 12..39

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 68.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Identical blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        async aggregateSessionsByUserId({
                                            uid,
                                            sort,
                                            search,
                                            offset = 0,
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 1 hr to fix
                                    packages/model-typings/src/models/ISessionsModel.ts on lines 40..52

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 61.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Identical blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        async getActiveUsersOfPeriodByDayBetweenDates({ start, end }: DestructuredRange): Promise<
                                            {
                                                day: number;
                                                month: number;
                                                year: number;
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 1 hr to fix
                                    packages/model-typings/src/models/ISessionsModel.ts on lines 60..68

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 57.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Identical blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        async aggregateSessionsAndPopulate({
                                            sort,
                                            search,
                                            offset = 0,
                                            count = 10,
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 55 mins to fix
                                    packages/model-typings/src/models/ISessionsModel.ts on lines 28..38

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 54.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                    const getProjectionByFullDate = (): { day: string; month: string; year: string } => ({
                                        day: '$_id.day',
                                        month: '$_id.month',
                                        year: '$_id.year',
                                    });
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 50 mins to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 169..173

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 52.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                    const getProjectionFullDate = (): { day: string; month: string; year: string } => ({
                                        day: '$day',
                                        month: '$month',
                                        year: '$year',
                                    });
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 50 mins to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 163..167

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 52.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                                    {
                                                        $or: [
                                                            {
                                                                month: { $lt: end.month },
                                                            },
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 50 mins to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 60..70
                                    apps/meteor/server/models/raw/Sessions.ts on lines 465..475

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 51.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                                        {
                                                            $or: [
                                                                {
                                                                    month: { $gt: startOfPeriodObject.month },
                                                                },
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 50 mins to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 60..70
                                    apps/meteor/server/models/raw/Sessions.ts on lines 71..81

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 51.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                                    {
                                                        $or: [
                                                            {
                                                                month: { $gt: start.month },
                                                            },
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 50 mins to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 71..81
                                    apps/meteor/server/models/raw/Sessions.ts on lines 465..475

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 51.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                                        {
                                                            $group: {
                                                                _id: {
                                                                    type: '$devices.device.type',
                                                                    name: '$devices.device.name',
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 50 mins to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 598..612

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 51.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                                    {
                                                        $group: {
                                                            _id: {
                                                                type: '$devices.device.type',
                                                                name: '$devices.device.name',
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 50 mins to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 545..559

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 51.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 4 locations. Consider refactoring.
                                    Open

                                        async logoutBySessionIdAndUserId({
                                            sessionId,
                                            userId,
                                        }: {
                                            sessionId: ISession['sessionId'];
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 3 other locations - About 40 mins to fix
                                    apps/meteor/server/models/raw/Analytics.ts on lines 107..133
                                    apps/meteor/server/models/raw/Analytics.ts on lines 215..217
                                    apps/meteor/server/models/raw/Integrations.ts on lines 36..47

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 48.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Identical blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        async getTotalOfSessionByHourAndDayBetweenDates({ start, end }: DateRange): Promise<
                                            {
                                                hour: number;
                                                day: number;
                                                month: number;
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 35 mins to fix
                                    packages/model-typings/src/models/ISessionsModel.ts on lines 86..94

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 47.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Identical blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                        async getUniqueUsersOfLastMonthOrWeek(
                                            collection: Collection<ISession>,
                                            { year, month, day, type = 'month' }: DestructuredDateWithType,
                                        ): Promise<UserSessionAggregation[]> {
                                            return collection
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 35 mins to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 529..579
                                    apps/meteor/server/models/raw/Sessions.ts on lines 632..683

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 46.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Identical blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                        getUniqueOSOfLastMonthOrWeek(
                                            collection: Collection<ISession>,
                                            { year, month, day, type = 'month' }: DestructuredDateWithType,
                                        ): Promise<OSSessionAggregation[]> {
                                            return collection
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 35 mins to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 346..429
                                    apps/meteor/server/models/raw/Sessions.ts on lines 529..579

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 46.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Identical blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                        async getUniqueDevicesOfLastMonthOrWeek(
                                            collection: Collection<ISession>,
                                            { year, month, day, type = 'month' }: DestructuredDateWithType,
                                        ): Promise<DeviceSessionAggregation[]> {
                                            return collection
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 35 mins to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 346..429
                                    apps/meteor/server/models/raw/Sessions.ts on lines 632..683

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 46.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                                    {
                                                        $group: {
                                                            _id: {
                                                                name: '$devices.device.os.name',
                                                                version: '$devices.device.os.version',
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 35 mins to fix
                                    apps/meteor/server/models/raw/LivechatAgentActivity.ts on lines 208..214
                                    apps/meteor/server/models/raw/Sessions.ts on lines 651..664

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 46.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                                        {
                                                            $group: {
                                                                _id: {
                                                                    name: '$devices.device.os.name',
                                                                    version: '$devices.device.os.version',
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 2 other locations - About 35 mins to fix
                                    apps/meteor/server/models/raw/LivechatAgentActivity.ts on lines 208..214
                                    apps/meteor/server/models/raw/Sessions.ts on lines 702..715

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 46.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 6 locations. Consider refactoring.
                                    Open

                                        findOneBySessionId(sessionId: string): Promise<ISession | null> {
                                            return this.findOne({ sessionId });
                                        }
                                    Severity: Major
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 5 other locations - About 30 mins to fix
                                    apps/meteor/server/models/raw/BaseUploadModel.ts on lines 94..96
                                    apps/meteor/server/models/raw/BaseUploadModel.ts on lines 98..100
                                    apps/meteor/server/models/raw/Integrations.ts on lines 16..18
                                    apps/meteor/server/models/raw/MatrixBridgedUser.ts on lines 26..28
                                    apps/meteor/server/models/raw/MatrixBridgedUser.ts on lines 42..44

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 45.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                            const session = await this.findOne<Pick<ISession, 'loginToken'>>(query, { projection: { loginToken: 1 } });
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 30 mins to fix
                                    apps/meteor/server/models/raw/Permissions.ts on lines 42..42

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 45.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                                        {
                                                            $match: {
                                                                type: 'user_daily',
                                                                ...aggregates.getMatchOfLastMonthOrWeek({ year, month, day, type }),
                                                            },
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 30 mins to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 353..358

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 45.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                                        {
                                                            $match: {
                                                                type: 'user_daily',
                                                                ...aggregates.getMatchOfLastMonthOrWeek({ year, month, day, type }),
                                                            },
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/Sessions.ts and 1 other location - About 30 mins to fix
                                    apps/meteor/server/models/raw/Sessions.ts on lines 536..541

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 45.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    There are no issues that match your filters.

                                    Category
                                    Status