Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactorize and test microservice/recordings #2826

Open
wants to merge 3 commits into
base: bleeding
Choose a base branch
from

Conversation

danigargar
Copy link
Contributor

Type Of Change

  • Small bug fix
  • New feature or enhancement
  • Breaking change

Checklist:

  • Commits are named and have tag following commit rules
  • Commits are split per component (schema, portal/platform, kamusers, agis, ..)
  • Changes have been tested locally
  • Fixes an existing issue (Fixes #XXXX)
  • Upport from existing Pull request #XXXX

Description

Additional information

@danigargar danigargar added +enhancement Enhancement microservices Microservices *tempest* IvozProvider 4.x Tempest Release labels Nov 25, 2024
@danigargar danigargar added this to the 4.4.0 milestone Nov 25, 2024
@danigargar danigargar self-assigned this Nov 25, 2024
@danigargar danigargar force-pushed the PROVIDER-2014-recordings-microservice-refactor branch 3 times, most recently from 4ae6502 to eb4d3b9 Compare November 25, 2024 12:27
Copy link

@ironArt3mis ironArt3mis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional review required

@danigargar danigargar force-pushed the PROVIDER-2014-recordings-microservice-refactor branch 3 times, most recently from 7973e0c to ff39243 Compare November 25, 2024 18:03
@danigargar danigargar force-pushed the PROVIDER-2014-recordings-microservice-refactor branch from ff39243 to 94c01dc Compare November 28, 2024 12:14
@danigargar danigargar force-pushed the PROVIDER-2014-recordings-microservice-refactor branch 3 times, most recently from 3a085c6 to df2fbbd Compare December 10, 2024 16:38
@danigargar danigargar force-pushed the PROVIDER-2014-recordings-microservice-refactor branch from df2fbbd to e6989bc Compare December 10, 2024 16:57
@danigargar danigargar requested a review from Kaian December 10, 2024 16:58

public function getCallid(): ?string
{
return ($this->callid);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra ()

$this->rawRecordingsDir,
$filename
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a check to only consider actual files and skip directories, links, and so on. The rawRecordingsDir may contain other files that are not actually Recordings.

Also, considering only files that ends with -mix.wav could be a good idea, because other files in the directory that doesn't match that pattern should be ingored, and not considered as errors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is also a good point to validate file format to extract callid from the filename

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This service is here only keep file system functions separated from the logic. It's fully mocked in testing.

Comment on lines +127 to +131
$this->rawRecordingInfoMockFactory(
'/recordings/wrong-file-name.ogg',
Encoder::RECORDING_SIZE_MIN + 1,
Encoder::RECORDING_AGE_MIN + 1
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be ignored by the recording microservice

Comment on lines +17 to +20
if (preg_match("/\w+-\w+-(.*)-\w+-mix.wav/", $this->filename, $matches)) {
$this->callid = urldecode($matches[1]);
$this->hashid = substr(md5($this->callid), 0, 8);
}
Copy link
Member

@Kaian Kaian Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will validate this before creating a RawRecordingInfo instance. If this condition doesn't match, it's not a recording and doesn't deserve a RawRecordingInfo. Also $this->callid and $this->hashid shouldn't be nullable. If the file doesn't have those values, it can not be considered a recording, so callid could be part of the constructor imo.

$billableCalls = $this
->billableCallRepository
->findByCallid(
$filename->getCallid() ?? ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned before, this should not happen. Callid is a must in the recording and should not be nullable.

@Kaian Kaian force-pushed the bleeding branch 2 times, most recently from df24ab3 to 842b736 Compare December 12, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
+enhancement Enhancement functional-review microservices Microservices *tempest* IvozProvider 4.x Tempest Release
Development

Successfully merging this pull request may close these issues.

4 participants